16. The rest

  Module predef


Method sin

float sin(float f)

Description

Returns the sine value for f . f should be specified in radians.

See also

asin() , cos() , tan()


Method asin

float asin(float f)

Description

Return the arcus sine value for f . The result will be in radians.

See also

sin() , acos()


Method cos

float cos(float f)

Description

Return the cosine value for f . f should be specified in radians.

See also

acos() , sin() , tan()


Method acos

float acos(float f)

Description

Return the arcus cosine value for f . The result will be in radians.

See also

cos() , asin()


Method tan

float tan(float f)

Description

Returns the tangent value for f . f should be specified in radians.

See also

atan() , sin() , cos()


Method atan

float atan(float f)

Description

Returns the arcus tangent value for f . The result will be in radians.

See also

tan() , asin() , acos() , atan2()


Method atan2

float atan2(float f1, float f2)

Description

Returns the arcus tangent value for f1 /f2 , and uses the signs of f1 and f2 to determine the quadrant. The result will be in radians.

See also

tan() , asin() , acos() , atan()


Method sqrt

float sqrt(float f)
int sqrt(int i)

Description

Returns the square root of f , or in the integer case, the square root truncated to the closest lower integer.

See also

pow() , log() , exp() , floor()


Method log

float log(float f)

Description

Return the natural logarithm of f .

exp( log(x) ) == x
for x > 0.

See also

pow() , exp()


Method exp

float exp(float f)

Description

Return the natural exponential of f .

log( exp( x ) ) == x
as long as exp(x) doesn't overflow an int.

See also

pow() , log()


Method pow

int|float pow(float|int n, float|int x)
mixed pow(object n, float|int|object x)

Description

Return n raised to the power of x . If both n and x are integers the result will be an integer. If n is an object its pow method will be called with x as argument.

See also

exp() , log()


Method floor

float floor(float f)

Description

Return the closest integer value less or equal to f .

Note

floor() does not return an int, merely an integer value stored in a float.

See also

ceil() , round()


Method ceil

float ceil(float f)

Description

Return the closest integer value greater or equal to f .

Note

ceil() does not return an int, merely an integer value stored in a float.

See also

floor() , round()


Method round

float round(float f)

Description

Return the closest integer value to f .

Note

round() does not return an int, merely an integer value stored in a float.

See also

floor() , ceil()


Method min

int|float|object min(int|float|object ... args)
string min(string ... args)

Description

Returns the smallest value among args . Compared objects must implement the lfun::`< method.

See also

max()


Method max

int|float|object max(int|float|object ... args)
string max(string ... args)

Description

Returns the largest value among args . Compared objects must implement the lfun::`< method.

See also

min()


Method abs

float abs(float f)
int abs(int f)
object abs(object f)

Description

Return the absolute value for f . If f is an object it must implement lfun::`< and unary lfun::`- .


Method sgn

int sgn(mixed value)
int sgn(mixed value, mixed zero)

Description

Check the sign of a value.

Returns

Returns -1 if value is less than zero , 1 if value is greater than zero and 0 (zero) otherwise.

See also

abs()


Method file_stat

Stdio.Stat file_stat(string path, void|int(0..1) symlink)

Description

Stat a file.

If the argument symlink is 1 symlinks will not be followed.

Returns

If the path specified by path doesn't exist 0 (zero) will be returned.

Otherwise an object describing the properties of path will be returned.

Note

In Pike 7.0 and earlier this function returned an array with 7 elements. The old behaviour can be simulated with the following function:

array(int) file_stat(string path, void|int(0..1) symlink)
         {
           File.Stat st = predef::file_stat(path, symlink);
           if (!st) return 0;
           return (array(int))st;
         }

See also

Stdio.Stat , Stdio.File->stat()


Method file_truncate

int file_truncate(string file, int length)

Description

Truncates the file file to the length specified in length .

Returns

Returns 1 if ok, 0 if failed.


Method filesystem_stat

mapping(string:int) filesystem_stat(string path)

Description

Returns a mapping describing the properties of the filesystem containing the path specified by path .

Returns

If a filesystem cannot be determined 0 (zero) will be returned.

Otherwise a mapping(string:int) with the following fields will be returned:

"blocksize" : int

Size in bytes of the filesystem blocks.

"blocks" : int

Size of the entire filesystem in blocks.

"bfree" : int

Number of free blocks in the filesystem.

"bavail" : int

Number of available blocks in the filesystem. This is usually somewhat less than the "bfree" value, and can usually be adjusted with eg tunefs(1M).

"files" : int

Total number of files (aka inodes) allowed by this filesystem.

"ffree" : int

Number of free files in the filesystem.

"favail" : int

Number of available files in the filesystem. This is usually the same as the "ffree" value, and can usually be adjusted with eg tunefs(1M).

"fsname" : int

Name assigned to the filesystem.

"fstype" : int

Type of filesystem (eg "nfs").


Note

Please note that not all members are present on all OSs.

See also

file_stat()


Method werror

void werror(string msg, mixed ... args)

Description

Write to standard error.


Method rm

int rm(string f)

Description

Remove a file or directory.

Returns

Returns 0 (zero) on failure, 1 otherwise.

See also

mkdir() , Stdio.recursive_rm()


Method mkdir

int mkdir(string dirname, void|int mode)

Description

Create a directory.

If mode is specified, it's will be used for the new directory after being &'ed with the current umask (on OS'es that support this).

Returns

Returns 0 (zero) on failure, 1 otherwise.

See also

rm() , cd() , Stdio.mkdirhier()


Method get_dir

array(string) get_dir(string dirname)

Description

Returns an array of all filenames in the directory dirname , or 0 (zero) if the directory does not exist.

See also

mkdir() , cd()


Method cd

int cd(string s)

Description

Change the current directory for the whole Pike process.

Returns

Returns 1 for success, 0 (zero) otherwise.

See also

getcwd()


Method getcwd

string getcwd()

Description

Returns the current working directory.

See also

cd()


Method exece

int exece(string file, array(string) args)
int exece(string file, array(string) args, mapping(string:string) env)

Description

This function transforms the Pike process into a process running the program specified in the argument file with the arguments args .

If the mapping env is present, it will completely replace all environment variables before the new program is executed.

Returns

This function only returns if something went wrong during exece(2), and in that case it returns 0 (zero).

Note

The Pike driver _dies_ when this function is called. You must either use fork() or Process.create_process() if you wish to execute a program and still run the Pike runtime.

See also

Process.create_process() , fork() , Stdio.File->pipe()


Method mv

int mv(string from, string to)

Description

Rename or move a file or directory.

If the destination already exists, it will be replaced. Replacement often only works if to is of the same type as from , i.e. a file can only be replaced by another file and so on. Also, a directory will commonly be replaced only if it's empty.

On some OSs this function can't move directories, only rename them.

Returns

Returns 0 (zero) on failure, 1 otherwise. Call errno() to get more error info on failure.

See also

rm()


Method strerror

string strerror(int errno)

Description

This function returns a description of an error code. The error code is usually obtained from eg Stdio.File->errno() .

Note

On some platforms the string returned can be somewhat nondescriptive.


Method errno

int errno()

Description

This function returns the system error from the last file operation.

Note

Note that you should normally use Stdio.File->errno() instead.

See also

Stdio.File->errno() , strerror()


Method _sprintf

string _sprintf(int type, void|mapping flags)


Method sprintf

string sprintf(string format, mixed ... args)

Description

Print formated output to string.

The format string is a string containing a description of how to output the data in args . This string should generally speaking have one %<modifiers><operator> format specifier (examples: %s, %0d, %-=20s) for each of the arguments.

The following modifiers are supported:

'0'

Zero pad numbers (implies right justification).

'!'

Toggle truncation.

' '

Pad positive integers with a space.

'+'

Pad positive integers with a plus sign.

'-'

Left adjust within field size (default is right).

'|'

Centered within field size.

'='

Column mode if strings are greater than field size.

'/'

Rough line break (break at exactly field size instead of between words).

'#'

Table mode, print a list of '\n' separated word (top-to-bottom order).

'$'

Inverse table mode (left-to-right order).

'n'

(Where n is a number or *) field size specifier.

'.n'

Precision specifier.

':n'

Field size precision specifier.

';n'

Column width specifier.

'*'

If n is a * then next argument is used for precision/field size.

"'"

Set a pad string. ' cannot be a part of the pad string (yet).

'~'

Get pad string from argument list.

'<'

Use same argument again.

'^'

Repeat this on every line produced.

'@@'

Repeat this format for each element in the argument array.

'>'

Put the string at the bottom end of column instead of top.

'_'

Set width to the length of data.

'[n]'

Select argument number n. Use * to use the next argument as selector.


The following operators are supported:

'%'

Percent.

'b'

Signed binary integer.

'd'

Signed decimal integer.

'u'

Unsigned decimal integer.

'o'

Signed octal integer.

'x'

Lowercase signed hexadecimal integer.

'X'

Uppercase signed hexadecimal integer.

'c'

Character. If a fieldsize has been specified this will output the low-order bytes of the integer in network byte order.

'f'

Float. (Locale dependent formatting.)

'g'

Heuristically chosen representation of float. (Locale dependent formatting.)

'G'

Like %g, but uses uppercase E for exponent.

'e'

Exponential notation float. (Locale dependent output.)

'E'

Like %e, but uses uppercase E for exponent.

'F'

Binary IEEE representation of float (%4F gives single precision, %8F gives double precision.)

's'

String.

'O'

Any value, debug style. Do not rely on the exact formatting; how the result looks can vary depending on locale, phase of the moon or anything else the _sprintf method implementor wanted for debugging.

'n'

No operation (ignore the argument).

't'

Type of the argument.

'{'

Perform the enclosed format for every element of the argument array.

'}'

Most modifiers and operators are combinable in any fashion, but some combinations may render strange results.

If an argument is an object that implements lfun::_sprintf() , that callback will be called with the operator as the first argument, and the current modifiers as the second. The callback is expected to return a string.

Example

Pike v7.3 release 11 running Hilfe v2.0 (Incremental Pike Frontend) > int screen_width=70; Result: 70 > mixed sample; > write(sprintf("fish: %c\n", 65)); fish: A Result: 8 > write(sprintf("Hello green friends\n")); Hello green friends Result: 20 > write(sprintf("num: %d\n", 10)); num: 10 Result: 8 > write(sprintf("num: %+10d\n", 10)); num: +10 Result: 16 > write(sprintf("num: %010d\n", 5*2)); num: 0000000010 Result: 16 > write(sprintf("num: %|10d\n", 20/2)); num: 10 Result: 16 > write(sprintf("%|*s\n",screen_width,"THE NOT END")); THE NOT END Result: 71 > write(sprintf("%|=*s\n",screen_width, "fun with penguins\n")); fun with penguins Result: 71 > write(sprintf("%-=*O\n",screen_width,({ "fish", 9, "gumbies", 2 }))); ({ /* 4 elements */ "fish", 9, "gumbies", 2 }) Result: 426 > write(sprintf("%-=*s\n", screen_width, >> "This will wordwrap the specified string within the "+ >> "specified field size, this is useful say, if you let "+ >> "users specify their screen size, then the room "+ >> "descriptions will automagically word-wrap as appropriate.\n"+ >> "slosh-n's will of course force a new-line when needed.\n")); This will wordwrap the specified string within the specified field size, this is useful say, if you let users specify their screen size, then the room descriptions will automagically word-wrap as appropriate. slosh-n's will of course force a new-line when needed. Result: 355 > write(sprintf("%-=*s %-=*s\n", screen_width/2, >> "Two columns next to each other (any number of columns will "+ >> "of course work) independantly word-wrapped, can be useful.", >> screen_width/2-1, >> "The - is to specify justification, this is in addherence "+ >> "to std sprintf which defaults to right-justification, "+ >> "this version also supports centre and right justification.")); Two columns next to each other (any The - is to specify justification, number of columns will of course this is in addherence to std work) independantly word-wrapped, sprintf which defaults to can be useful. right-justification, this version also supports centre and right justification. Result: 426 > write(sprintf("%-$*s\n", screen_width, >> "Given a\nlist of\nslosh-n\nseparated\n'words',\nthis option\n"+ >> "creates a\ntable out\nof them\nthe number of\ncolumns\n"+ >> "be forced\nby specifying a\npresision.\nThe most obvious\n"+ >> "use is for\nformatted\nls output.")); Given a list of slosh-n separated 'words', this option creates a table out of them the number of columns be forced by specifying a presision. The most obvious use is for formatted ls output. Result: 312 > write(sprintf("%-#*s\n", screen_width, >> "Given a\nlist of\nslosh-n\nseparated\n'words',\nthis option\n"+ >> "creates a\ntable out\nof them\nthe number of\ncolumns\n"+ >> "be forced\nby specifying a\npresision.\nThe most obvious\n"+ >> "use is for\nformatted\nls output.")); Given a creates a by specifying a list of table out presision. slosh-n of them The most obvious separated the number of use is for 'words', columns formatted this option be forced ls output. Result: 312 > sample = ([ "align":"left", "valign":"middle" ]); Result: ([ /* 2 elements */ "align":"left", "valign":"middle" ]) > write(sprintf("<td%{ %s='%s'%}>\n", (array)sample)); <td valign='middle' align='left'> Result: 34 > write(sprintf("Of course all the simple printf options "+ >> "are supported:\n %s: %d %x %o %c\n", >> "65 as decimal, hex, octal and a char", >> 65, 65, 65, 65)); Of course all the simple printf options are supported: 65 as decimal, hex, octal and a char: 65 41 101 A Result: 106 > write(sprintf("%[0]d, %[0]x, %[0]X, %[0]o, %[0]c\n", 75)); 75, 4b, 4B, 113, K Result: 19 > write(sprintf("%|*s\n",screen_width, "THE END")); THE END Result: 71

See also

lfun::_sprintf()


Method getgrgid

array(int|string|array(string)) getgrgid(int gid)

Description

Get the group entry for the group with the id gid using the systemfunction getgrid(3).

Parameter gid

The id of the group

Returns

An array with the information about the group

Array
string 0

Group name

string 1

Group password (encrypted)

int 2

ID of the group

array 3..

Array with UIDs of group members


See also

getgrent() getgrnam()


Method getgrnam

array(int|string|array(string)) getgrnam(string str)

Description

Get the group entry for the group with the name str using the systemfunction getgrnam(3).

Parameter str

The name of the group

Returns

An array with the information about the group

Array
string 0

Group name

string 1

Group password (encrypted)

int 2

ID of the group

array 3..

Array with UIDs of group members


See also

getgrent() getgrgid()


Method getpwnam

array(int|string) getpwnam(string str)

Description

Get the user entry for login str using the systemfunction getpwnam(3).

Parameter str

The login name of the user whos userrecord is requested.

Returns

An array with the information about the user

Array
string 0

Users username (loginname)

string 1

User password (encrypted)

int 2

Users ID

int 3

Users primary group ID

string 4

Users real name an possibly some other info

string 5

Users home directory

string 6

Users shell


See also

getpwuid() getpwent()


Method getpwuid

array(int|string) getpwuid(int uid)

Description

Get the user entry for UID uid using the systemfunction getpwuid(3).

Parameter uid

The uid of the user whos userrecord is requested.

Returns

An array with the information about the user

Array
string 0

Users username (loginname)

string 1

User password (encrypted)

int 2

Users ID

int 3

Users primary group ID

string 4

Users real name an possibly some other info

string 5

Users home directory

string 6

Users shell


See also

getpwnam() getpwent()


Method setpwent

int setpwent()

Description

Resets the getpwent function to the first entry in the passwd source using the systemfunction setpwent(3).

Returns

Always 0 (zero)

See also

getpwent() endpwent()


Method endpwent

int endpwent()

Description

Closes the passwd source opened by getpwent function using the systemfunction endpwent(3).

Returns

Always 0 (zero)

See also

getpwent() setpwent()


Method getpwent

array(int|string) getpwent()

Description

When first called, the getpwent function opens the passwd source and returns the first record using the systemfunction getpwent(3). For each following call, it returns the next record until EOF.

Call endpwent when done using getpwent .

Returns

An array with the information about the user

Array
string 0

Users username (loginname)

string 1

User password (encrypted)

int 2

Users ID

int 3

Users primary group ID

string 4

Users real name an possibly some other info

string 5

Users home directory

string 6

Users shell


0 if EOF.

See also

getpwnam() getpwent() setpwent() endpwent()


Method get_all_users

array(array(int|string)) get_all_users()

Description

Returns an array with all users in the system.

Returns

An array with arrays of userinfo as in getpwent .

See also

getpwent() getpwnam() getpwuid()


Method setgrent

int setgrent()

Description

Rewinds the getgrent pointer to the first entry

See also

getgrent() endgrent()


Method endgrent

int endgrent()

Description

Closes the /etc/groups file after using the getgrent function.

See also

getgrent() setgrent()


Method getgrent

array(int|string|array(string)) getgrent()

Description

Get a group entry from /etc/groups file. getgrent interates thru the groups source and returns one entry per call using the systemfunction getgrent(3).

Always call endgrent when done using getgrent !

Returns

An array with the information about the group

Array
string 0

Group name

string 1

Group password (encrypted)

int 2

ID of the group

array 3..

Array with UIDs of group members


See also

getgrnam() getgrgid()


Method get_all_groups

array(array(int|string|array(string))) get_all_groups()

Description

Returns an array of arrays with all groups in the system groups source. Each element in the returned array has the same structure as in getgrent function.

Note

The groups source is system dependant. Refer to your system manuals for information about how to set the source.

Returns
Array
array(int|string|array(string)) 0..

Array with info about the group


See also

getgrent()


Method get_groups_for_user

array(int) get_groups_for_user(int|string user)

Description

Gets all groups which a given user is a member of.

Parameter user

UID or loginname of the user

Returns
Array
array 0..

Information about all the users groups


See also

get_all_groups() getgrgid() getgrnam() getpwuid() getpwnam()


Method equal

int equal(mixed a, mixed b)

Description

This function checks if the values a and b are equal.

For all types but arrays, multisets and mappings, this operation is the same as doing

a  == b 
. For arrays, mappings and multisets however, their contents are checked recursively, and if all their contents are the same and in the same place, they are considered equal.

See also

copy_value()


Method aggregate

array aggregate(mixed ... elements)

Description

Construct an array with the arguments as indices.

This function could be written in Pike as:

array aggregate(mixed ... elems) { return elems; }

Note

Arrays are dynamically allocated there is no need to declare them like

int a[10]=allocate(10);
(and it isn't possible either) like in C, just
array(int) a=allocate(10);
will do.

See also

sizeof() , arrayp() , allocate()


Method hash_7_0

int hash_7_0(string s)
int hash_7_0(string s, int max)

Description

This function will return an int derived from the string s . The same string will always hash to the same value. If max is given, the result will be >= 0 and < max , otherwise the result will be >= 0 and <= 0x7fffffff.

Note

This function is provided for backward compatibility reasons.

See also

hash()


Method hash

int hash(string s)
int hash(string s, int max)

Description

This function will return an int derived from the string s . The same string will always hash to the same value. If max is given, the result will be >= 0 and < max , otherwise the result will be >= 0 and <= 0x7fffffff.

Note

The hash algorithm was changed in Pike 7.1. If you want a hash that is compatible with Pike 7.0 and earlier, use hash_7_0() .

See also

hash_7_0()


Method copy_value

mixed copy_value(mixed value)

Description

Copy a value recursively.

If the result value is changed destructively (only possible for multisets, arrays and mappings) the copied value will not be changed.

The resulting value will always be equal to the copied (as tested with the function equal() ), but they may not the the same value (as tested with `==() ).

See also

equal()


Method lower_case

string lower_case(string s)

Description

Convert a string to lower case.

Returns

Returns a copy of the string s with all upper case characters converted to lower case.

See also

upper_case()


Method upper_case

string upper_case(string s)

Description

Convert a string to upper case.

Returns

Returns a copy of the string s with all lower case characters converted to upper case.

See also

lower_case()


Method random_string

string random_string(int len)

Description

Returns a string of random characters 0-255 with the length len .


Method random_seed

void random_seed(int seed)

Description

This function sets the initial value for the random generator.

See also

random()


Method query_num_arg

int query_num_arg()

Description

Returns the number of arguments given when the previous function was called.

This is useful for functions that take a variable number of arguments.

See also

call_function()


Method search

int search(string haystack, string|int needle, int|void start)
int search(array haystack, mixed needle, int|void start)
mixed search(mapping haystack, mixed needle, mixed|void start)

Description

Search for needle in haystack . Return the position of needle in haystack or -1 if not found.

If the optional argument start is present search is started at this position.

When haystack is a string needle must be a string or an int, and the first occurrence of the string or int is returned.

When haystack is an array, needle is compared only to one value at a time in haystack .

When haystack is a mapping, search() tries to find the index connected to the data needle . That is, it tries to lookup the mapping backwards. If needle isn't present in the mapping, zero is returned, and zero_type() will return 1 for this zero.

See also

indices() , values() , zero_type()


Method has_prefix

int has_prefix(string s, string prefix)

Description

Returns 1 if the string s starts with prefix , returns 0 (zero) otherwise.


Method has_suffix

int has_suffix(string s, string suffix)

Description

Returns 1 if the string s ends with suffix , returns 0 (zero) otherwise.


Method has_index

int has_index(string haystack, int index)
int has_index(array haystack, int index)
int has_index(mapping|multiset|object|program haystack, mixed index)

Description

Search for index in haystack .

Returns

Returns 1 if index is in the index domain of haystack , or 0 (zero) if not found.

This function is equivalent to (but sometimes faster than):

search(indices(haystack), index) != -1

Note

A negative index in strings and arrays as recognized by the index operators `[]() and `[]=() is not considered a proper index by has_index()

See also

has_value() , indices() , search() , values() , zero_type()


Method has_value

int has_value(string haystack, string value)
int has_value(string haystack, int value)
int has_value(array|mapping|object|program haystack, mixed value)

Description

Search for value in haystack .

Returns

Returns 1 if value is in the value domain of haystack , or 0 (zero) if not found.

This function is in all cases except when both arguments are strings equivalent to (but sometimes faster than):

search(values(haystack ), value ) != -1

If both arguments are strings, has_value() is equivalent to:

search(haystack , value ) != -1

See also

has_index() , indices() , search() , values() , zero_type()


Method add_constant

void add_constant(string name, mixed value)
void add_constant(string name)

Description

Add a new predefined constant.

This function is often used to add builtin functions. All programs compiled after the add_constant() function has been called can access value by the name name .

If there is a constant called name already, it will be replaced by by the new definition. This will not affect already compiled programs.

Calling add_constant() without a value will remove that name from the list of constants. As with replacing, this will not affect already compiled programs.

See also

all_constants()


Method combine_path
Method combine_path_unix
Method combine_path_nt

string combine_path(string absolute, string ... relative)
string combine_path_unix(string absolute, string ... relative)
string combine_path_nt(string absolute, string ... relative)

Description

Concatenate a relative path to an absolute path and remove any "//", "/.." or "/." to produce a straightforward absolute path as result.

combine_path_nt() concatenates according to NT-filesystem conventions, while combine_path_unix() concatenates according to UNIX-style.

combine_path() is equvivalent to combine_path_unix() on UNIX-like operating systems, and equvivalent to combine_path_nt() on NT-like operating systems.

See also

getcwd() , Stdio.append_path()


Method zero_type

int zero_type(mixed a)

Description

Return the type of zero.

There are many types of zeros out there, or at least there are two. One is returned by normal functions, and one returned by mapping lookups and find_call_out() when what you looked for wasn't there. The only way to separate these two kinds of zeros is zero_type() .

Returns

When doing a find_call_out() or mapping lookup, zero_type() on this value will return 1 if there was no such thing present in the mapping, or if no such call_out could be found.

If the argument to zero_type() is a destructed object or a function in a destructed object, 2 will be returned.

In all other cases zero_type() will return 0 (zero).

See also

find_call_out()


Method string_to_unicode

string string_to_unicode(string s)

Description

Converts a string into an UTF16 compliant byte-stream.

Note

Throws an error if characters not legal in an UTF16 stream are encountered. Valid characters are in the range 0x00000 - 0x10ffff, except for characters 0xfffe and 0xffff.

Characters in range 0x010000 - 0x10ffff are encoded using surrogates.

See also

Locale.Charset.decoder() , string_to_utf8() , unicode_to_string() , utf8_to_string()


Method unicode_to_string

string unicode_to_string(string s)

Description

Converts an UTF16 byte-stream into a string.

Note

This function did not decode surrogates in Pike 7.2 and earlier.

See also

Locale.Charset.decoder() , string_to_unicode() , string_to_utf8() , utf8_to_string()


Method string_to_utf8

string string_to_utf8(string s)
string string_to_utf8(string s, int extended)

Description

Converts a string into an UTF8 compliant byte-stream.

Note

Throws an error if characters not valid in an UTF8 stream are encountered. Valid characters are in the range 0x00000000 - 0x7fffffff.

If extended is 1, characters in the range 0x80000000-0xfffffffff will also be accepted, and encoded using a non-standard UTF8 extension.

See also

Locale.Charset.encoder() , string_to_unicode() , unicode_to_string() , utf8_to_string()


Method utf8_to_string

string utf8_to_string(string s)
string utf8_to_string(string s, int extended)

Description

Converts an UTF8 byte-stream into a string.

Note

Throws an error if the stream is not a legal UFT8 byte-stream.

Accepts and decodes the extension used by string_to_utf8() , if extended is 1.

See also

Locale.Charset.encoder() , string_to_unicode() , string_to_utf8() , unicode_to_string()


Method __parse_pike_type

string __parse_pike_type(string t)


Method all_constants

mapping(string:mixed) all_constants()

Description

Returns a mapping containing all global constants, indexed on the name of the constant, and with the value of the constant as value.

See also

add_constant()


Method allocate

array allocate(int size)
array allocate(int size, mixed zero)

Description

Allocate an array of size elements and initialize them to zero .

See also

sizeof() , aggregate() , arrayp()


Method rusage

array(int) rusage()

Description

Return resource usage.

Returns

Returns an array of ints describing how much resources the interpreter process has used so far. This array will have at least 29 elements, of which those values not available on this system will be zero.

The elements are as follows:

Array
int user_time

Time in milliseconds spent in user code.

int system_time

Time in milliseconds spent in system calls.

int maxrss

Maximum used resident size in kilobytes.

int ixrss

Quote from GNU libc: An integral value expressed in kilobytes times ticks of execution, which indicates the amount of memory used by text that was shared with other processes.

int idrss

Quote from GNU libc: An integral value expressed the same way, which is the amount of unshared memory used for data.

int isrss

Quote from GNU libc: An integral value expressed the same way, which is the amount of unshared memory used for stack space.

int minor_page_faults

Minor page faults, i.e. TLB misses which required no disk I/O.

int major_page_faults

Major page faults, i.e. paging with disk I/O required.

int swaps

Number of times the process was swapped out entirely.

int block_input_op

Number of block input operations.

int block_output_op

Number of block output operations.

int messages_sent

Number of IPC messsages sent.

int messages_received

Number of IPC messsages received.

int signals_received

Number of signals received.

int voluntary_context_switches

Number of voluntary context switches (usually to wait for some service).

int involuntary_context_switches

Number of preemptions, i.e. context switches due to expired time slices, or when processes with higher priority were scheduled.

int sysc

Number of system calls.

int ioch

?

int rtime

?

int ttime

?

int tftime

?

int dftime

?

int kftime

?

int ltime

?

int slptime

?

int wtime

?

int stoptime

?

int brksize

Heap size.

int stksize

Stack size.


The values will not be further explained here; read your system manual for more information.

Note

All values may not be present on all systems.

See also

time()


Method this_object

object this_object(void|int level)

Description

Returns the object we are currently evaluating in.

level might be used to access the object of a surrounding class: The object at level 0 is the current object, the object at level 1 is the one belonging to the class that surrounds the class that the object comes from, and so on.

Note

As opposed to a qualified this reference such as global::this, this function doesn't always access the objects belonging to the lexically surrounding classes. If the class containing the call has been inherited then the objects surrounding the inheriting class are accessed.


Method throw

void throw(mixed value)

Description

Throw value to a waiting catch .

If no catch is waiting the global error handling will send the value to master()->handle_error() .

If you throw an array with where the first index contains an error message and the second index is a backtrace, (the output from backtrace() ) then it will be treated exactly like a real error by overlying functions.

See also

catch


Method exit

void exit(int returncode)

Description

Exit the whole Pike program with the given returncode .

Using exit() with any other value than 0 (zero) indicates that something went wrong during execution. See your system manuals for more information about return codes.

See also

_exit()


Method _exit

void _exit(int returncode)

Description

This function does the same as exit , but doesn't bother to clean up the Pike interpreter before exiting. This means that no destructors will be called, caches will not be flushed, file locks might not be released, and databases might not be closed properly.

Use with extreme caution.

See also

exit()


Method time

int time()
int time(int(1..1) one)
float time(int(2..) t)

Description

This function returns the number of seconds since 00:00:00 UTC, Jan 1, 1970.

The second syntax does not call the system call time() as often, but is only updated in the backed (when Pike code isn't running).

The third syntax can be used to measure time more preciely than one second. It return how many seconds has passed since t . The precision of this function varies from system to system.

See also

ctime() , localtime() , mktime() , gmtime()


Method crypt

string crypt(string password)
int(0..1) crypt(string typed_password, string crypted_password)

Description

This function crypts and verifies a short string (only the first 8 characters are significant).

The first syntax crypts the string password into something that is hopefully hard to decrypt.

The second syntax is used to verify typed_password against crypted_password , and returns 1 if they match, and 0 (zero) otherwise.


Method destruct

void destruct(object o)

Description

Mark an object as destructed.

Calls o->destroy(), and then clears all variables in the object.

All pointers and function pointers to this object will become zero. The destructed object will be freed from memory as soon as possible.


Method indices

array indices(string|array|mapping|multiset|object x)

Description

Return an array of all valid indices for the value x .

For strings and arrays this is simply an array of ascending numbers.

For mappings and multisets, the array may contain any value.

For objects which define lfun::_indices() that return value will be used.

For other objects an array with all non-static symbols will be returned.

See also

values()


Method values

array values(string|array|mapping|multiset|object x)

Description

Return an array of all possible values from indexing the value x .

For strings an array of int with the ISO10646 codes of the characters in the string is returned.

For a multiset an array filled with ones (1) is returned.

For arrays a single-level copy of x is returned.

For mappings the array may contain any value.

For objects which define lfun::_values() that return value will be used.

For other objects an array with the values of all non-static symbols will be returned.

See also

indices()


Method next_object

object next_object(object o)
object next_object()

Description

Returns the next object from the list of all objects.

All objects are stored in a linked list.

Returns

If no arguments have been given next_object() will return the first object from the list.

If o has been specified the object after o on the list will be returned.

Note

This function is not recomended to use.

See also

destruct()


Method object_program

program object_program(mixed o)

Description

Return the program from which o was instantiated.

If o is not an object or has been destructed 0 (zero) will be returned.


Method reverse

string reverse(string s)
array reverse(array a)
int reverse(int i)

Description

Reverses a string, array or int.

This function reverses a string, char by char, an array, value by value or an int, bit by bit and returns the result. It's not destructive on the input value.

Reversing strings can be particularly useful for parsing difficult syntaxes which require scanning backwards.

See also

sscanf()


Method replace

string replace(string s, string from, string to)
string replace(string s, array(string) from, array(string) to)
string replace(string s, mapping(string:string) replacements)
array replace(array a, mixed from, mixed to)
mapping replace(mapping a, mixed from, mixed to)

Description

Generic replace function.

This function can do several kinds replacement operations, the different syntaxes do different things as follows:

If all the arguments are strings, a copy of s with every occurrence of from replaced with to will be returned. Special case: to will be inserted between every character in s if from is the empty string.

If the first argument is a string, and the others array(string), a string with every occurrance of from [i] in s replaced with to [i] will be returned. Instead of the arrays from and to a mapping equvivalent to

mkmapping (from , to )
can be used.

If the first argument is an array or mapping, the values of a which are `==() with from will be replaced with to destructively. a will then be returned.

Note

Note that replace() on arrays and mappings is a destructive operation.


Method compile

program compile(string source, object|void handler, int|void major, int|void minor, program|void target, object|void placeholder)

Description

Compile a string to a program.

This function takes a piece of Pike code as a string and compiles it into a clonable program.

The optional argument handler is used to specify an alternative error handler. If it is not specified the current master object will be used.

The optional arguments major and minor are used to tell the compiler to attempt to be compatible with Pike major .minor .

Note

Note that source must contain the complete source for a program. It is not possible to compile a single expression or statement.

Also note that compile() does not preprocess the program. To preprocess the program you can use compile_string() or call the preprocessor manually by calling cpp() .

See also

compile_string() , compile_file() , cpp() , master()


Method set_weak_flag

array|mapping|multiset set_weak_flag(array|mapping|multiset m, int state)

Description

Set the value m to use weak or normal references in its indices and/or values (whatever is applicable). state is a bitfield built by using | between the following flags:

Pike.WEAK_INDICES

Use weak references for indices. Only applicable for multisets and mappings.

Pike.WEAK_VALUES

Use weak references for values. Only applicable for arrays and mappings.

Pike.WEAK

Shorthand for Pike.WEAK_INDICES|Pike.WEAK_VALUES.


If a flag is absent, the corresponding field will use normal references. state can also be 1 as a compatibility measure; it's treated like Pike.WEAK .

Returns

m will be returned.


Method objectp

int objectp(mixed arg)

Description

Returns 1 if arg is an object, 0 (zero) otherwise.

See also

mappingp() , programp() , arrayp() , stringp() , functionp() , multisetp() , floatp() , intp()


Method functionp

int functionp(mixed arg)

Description

Returns 1 if arg is a function, 0 (zero) otherwise.

See also

mappingp() , programp() , arrayp() , stringp() , objectp() , multisetp() , floatp() , intp()


Method callablep

int callablep(mixed arg)

Description

Returns 1 if arg is a callable, 0 (zero) otherwise.

See also

mappingp() , programp() , arrayp() , stringp() , objectp() , multisetp() , floatp() , intp()


Method sleep

void sleep(int|float s, void|int abort_on_signal)

Description

This function makes the program stop for s seconds.

Only signal handlers can interrupt the sleep, and only when abort_on_signal is set. If more than one thread is running the signal must be sent to the sleeping thread. Other callbacks are not called during sleep.

See also

signal() , delay()


Method delay

void delay(int|float s)

Description

This function makes the program stop for s seconds.

Only signal handlers can interrupt the sleep. Other callbacks are not called during delay. Beware that this function uses busy-waiting to achieve the highest possible accuracy.

See also

signal() , sleep()


Method gc

int gc()

Description

Force garbage collection.

This function checks all the memory for cyclic structures such as arrays containing themselves and frees them if appropriate. It also frees up destructed objects and things with only weak references. It then returns how many arrays/objects/programs/etc. it managed to free by doing this.

Normally there is no need to call this function since Pike will call it by itself every now and then. (Pike will try to predict when 20% of all arrays/object/programs in memory is 'garbage' and call this routine then.)


Method programp

int programp(mixed arg)

Description

Returns 1 if arg is a program, 0 (zero) otherwise.

See also

mappingp() , intp() , arrayp() , stringp() , objectp() , multisetp() , floatp() , functionp()


Method intp

int intp(mixed arg)

Description

Returns 1 if arg is an int, 0 (zero) otherwise.

See also

mappingp() , programp() , arrayp() , stringp() , objectp() , multisetp() , floatp() , functionp()


Method mappingp

int mappingp(mixed arg)

Description

Returns 1 if arg is a mapping, 0 (zero) otherwise.

See also

intp() , programp() , arrayp() , stringp() , objectp() , multisetp() , floatp() , functionp()


Method arrayp

int arrayp(mixed arg)

Description

Returns 1 if arg is an array, 0 (zero) otherwise.

See also

intp() , programp() , mappingp() , stringp() , objectp() , multisetp() , floatp() , functionp()


Method multisetp

int multisetp(mixed arg)

Description

Returns 1 if arg is a multiset, 0 (zero) otherwise.

See also

intp() , programp() , arrayp() , stringp() , objectp() , mappingp() , floatp() , functionp()


Method stringp

int stringp(mixed arg)

Description

Returns 1 if arg is a string, 0 (zero) otherwise.

See also

intp() , programp() , arrayp() , multisetp() , objectp() , mappingp() , floatp() , functionp()


Method floatp

int floatp(mixed arg)

Description

Returns 1 if arg is a float, 0 (zero) otherwise.

See also

intp() , programp() , arrayp() , multisetp() , objectp() , mappingp() , stringp() , functionp()


Method sort

array sort(array(mixed) index, array(mixed) ... data)

Description

Sort arrays destructively.

This function sorts the array index destructively. That means that the array itself is changed and returned, no copy is created.

If extra arguments are given, they are supposed to be arrays of the same size as index . Each of these arrays will be modified in the same way as index . I.e. if index 3 is moved to position 0 in index index 3 will be moved to position 0 in all the other arrays as well.

sort() can sort strings, integers and floats in ascending order. Arrays will be sorted first on the first element of each array. Objects will be sorted in ascending order according to `<() , `>() and `==() .

Returns

The first argument will be returned.

Note

The sorting algorithm used is not stable, ie elements that are equal may get reordered.

See also

reverse()


Method rows

array rows(mixed data, array index)

Description

Select a set of rows from an array.

This function is en optimized equivalent to:

map(index , lambda(mixed x) { return data [x]; })

That is, it indices data on every index in the array index and returns an array with the results.

See also

column()


Method gmtime

mapping(string:int) gmtime(int timestamp)

Description

Convert seconds since 00:00:00 UTC, Jan 1, 1970 into components.

This function works like localtime() but the result is not adjusted for the local time zone.

See also

localtime() , time() , ctime() , mktime()


Method localtime

mapping(string:int) localtime(int timestamp)

Description

Convert seconds since 00:00:00 UTC, Jan 1, 1970 into components.

Returns

This function returns a mapping with the following components:

"sec" : int(0..60)

Seconds over the minute.

"min" : int(0..59)

Minutes over the hour.

"hour" : int(0..23)

Hour of the day.

"mday" : int(1..31)

Day of the month.

"mon" : int(0..11)

Month of the year.

"year" : int(0..)

Year since 1900.

"wday" : int(0..6)

Day of week (0 = Sunday).

"yday" : int(0..365)

Day of the year.

"isdst" : int(0..1)

Is daylight savings time.

"timezone" : int

Offset from UTC.


An error is thrown if the localtime(2) call failed on the system. It's platform dependent what time ranges that function can handle, e.g. Windows doesn't handle a negative timestamp .

Note

The field "timezone" may not be available on all platforms.

See also

Calendar , gmtime() , time() , ctime() , mktime()


Method mktime

int mktime(mapping(string:int) tm)
int mktime(int sec, int min, int hour, int mday, int mon, int year, int isdst, int tz)

Description

This function converts information about date and time into an integer which contains the number of seconds since 00:00:00 UTC, Jan 1, 1970.

You can either call this function with a mapping containing the following elements:

"sec" : int(0..60)

Seconds over the minute.

"min" : int(0..59)

Minutes over the hour.

"hour" : int(0..23)

Hour of the day.

"mday" : int(1..31)

Day of the month.

"mon" : int(0..11)

Month of the year.

"year" : int(0..)

Year since 1900.

"isdst" : int(0..1)

Is daylight savings time.

"timezone" : int

The timezone offset from UTC in seconds. If left out, the time will be calculated in the local timezone.


Or you can just send them all on one line as the second syntax suggests.

Note

On some operating systems (notably AIX), dates before 00:00:00 UTC, Jan 1, 1970 are not supported.

On most systems, the supported range of dates are Dec 13, 1901 20:45:52 UTC through Jan 19, 2038 03:14:07 UTC (inclusive).

See also

time() , ctime() , localtime() , gmtime()


Method parse_format

array parse_format(string fmt)

Description

Parses a sprintf/sscanf-style format string


Method glob

int(0..1) glob(string glob, string str)
array(string) glob(string glob, array(string) arr)

Description

Match strings against globs.

In a glob string a question sign matches any character and an asterisk matches any string.

When the second argument is a string and str matches the glob glob 1 will be returned, 0 (zero) otherwise.

If the second array is an array and array containing the strings in arr that match glob will be returned.

See also

sscanf() , Regexp


Method _next

mixed _next(mixed x)

Description

Find the next object/array/mapping/multiset/program or string.

All objects, arrays, mappings, multisets, programs and strings are stored in linked lists inside Pike. This function returns the next item on the corresponding list. It is mainly meant for debugging the Pike runtime, but can also be used to control memory usage.

See also

next_object() , _prev()


Method _prev

mixed _prev(mixed x)

Description

Find the previous object/array/mapping/multiset or program.

All objects, arrays, mappings, multisets and programs are stored in linked lists inside Pike. This function returns the previous item on the corresponding list. It is mainly meant for debugging the Pike runtime, but can also be used to control memory usage.

Note

Unlike _next() this function does not work on strings.

See also

next_object() , _next()


Method _refs

int _refs(string|array|mapping|multiset|function|object|program o)

Description

Return the number of references o has.

It is mainly meant for debugging the Pike runtime, but can also be used to control memory usage.

Note

Note that the number of references will always be at least one since the value is located on the stack when this function is executed.

See also

_next() , _prev()


Method _typeof

type _typeof(mixed x)

Description

Return the runtime type of x .

See also

typeof()


Method replace_master

void replace_master(object o)

Description

Replace the master object with o .

This will let you control many aspects of how Pike works, but beware that master.pike may be required to fill certain functions, so it is usually a good idea to have your master inherit the original master and only re-define certain functions.

FIXME: Tell how to inherit the master.

See also

master()


Method master

object master()

Description

Return the current master object.

See also

replace_master()


Method gethrvtime

int gethrvtime()


Method gethrtime

int gethrtime()


Method get_profiling_info

array(int|mapping(string:array(int))) get_profiling_info(program prog)

Description

Get profiling information.

Returns

Returns an array with two elements.

Array
int num_clones

The first element is the number of times the program prog has been instantiated.

mapping(string:array(int)) fun_prof_info

The second element is mapping from function name to an array with three elements.

Array
int num_calls

The first element is the number of times the function has been called.

int total_time

The second element is the total time (in milliseconds) spent executing this function, and any functions called from it.

int self_time

The third element is the time (in milliseconds) actually spent in this function so far.



Note

This function is only available if the runtime was compiled with the option --with-profiling.


Method object_variablep

int(0..1) object_variablep(object o, string var)

Description

Find out if an object identifier is a variable.

Returns

This function returns 1 if var exists as a non-static variable in o , and returns 0 (zero) otherwise.

See also

indices() , values()


Method map_array

array map_array(array arr, function fun, mixed ... args)
array map_array(array(object) arr, string fun, mixed ... args)
array map_array(array(function) arr, int(-1..-1) minus_one, mixed ... args)

Description

This function is similar to map() .

Note

This function has been deprecated in favour of map() .

See also

map()


Method map

mixed map(mixed arr, void|mixed fun, mixed ... extra)

Description

Applies fun to the elements in arr and collects the results.

arr is treated as a set of elements, as follows:

array
multiset
string

fun is applied in order to each element. The results are collected, also in order, to a value of the same type as arr , which is returned.

mapping

fun is applied to the values, and each result is assigned to the same index in a new mapping, which is returned.

program

The program is treated as a mapping containing the identifiers that are indexable from it and their values.

object

If there is a

cast
method in the object, it's called to try to cast the object to an array, a mapping, or a multiset, in that order, which is then handled as described above.

fun is applied in different ways depending on its type:

function

fun is called for each element. It gets the current element as the first argument and extra as the rest. The result of the call is collected.

object

fun is used as a function like above, i.e. the

`()
method in it is called.

multiset
mapping

fun is indexed with each element. The result of that is collected.

zero or left out

Each element that is callable is called with extra as arguments. The result of the calls are collected. Elements that aren't callable gets zero as result.

string

Each element is indexed with the given string. If the result of that is zero then a zero is collected, otherwise it's called with extra as arguments and the result of that call is collected.

This is typically used when arr is a collection of objects, and fun is the name of some function in them.

Note

The function is never destructive on arr .

See also

filter() , enumerate() , foreach()


Method filter

mixed filter(mixed arr, void|mixed fun, mixed ... extra)

Description

Filters the elements in arr through fun .

arr is treated as a set of elements to be filtered, as follows:

array
multiset
string

Each element is filtered with fun . The return value is of the same type as arr and it contains the elements that fun accepted. fun is applied in order to each element, and that order is retained between the kept elements.

If fun is an array, it should have the same length as arr . In this case, the elements in arr are kept where the corresponding positions in fun are nonzero. Otherwise fun is used as described below.

mapping

The values are filtered with fun , and the index/value pairs it accepts are kept in the returned mapping.

program

The program is treated as a mapping containing the identifiers that are indexable from it and their values.

object

If there is a

cast
method in the object, it's called to try to cast the object to an array, a mapping, or a multiset, in that order, which is then filtered as described above.

Unless something else is mentioned above, fun is used as filter like this:

function

fun is called for each element. It gets the current element as the first argument and extra as the rest. The element is kept if it returns true, otherwise it's filtered out.

object

The object is used as a function like above, i.e. the

`()
method in it is called.

multiset
mapping

fun is indexed with each element. The element is kept if the result is nonzero, otherwise it's filtered out.

zero or left out

Each element that is callable is called with extra as arguments. The element is kept if the result of the call is nonzero, otherwise it's filtered out. Elements that aren't callable are also filtered out.

string

Each element is indexed with the given string. If the result of that is zero then the element is filtered out, otherwise the result is called with extra as arguments. The element is kept if the return value is nonzero, otherwise it's filtered out.

This is typically used when arr is a collection of objects, and fun is the name of some predicate function in them.

Note

The function is never destructive on arr .

See also

map() , foreach()


Method enumerate

array(int) enumerate(int n)
array enumerate(int n, void|mixed step, void|mixed start, void|function operator)

Description

Create an array with an enumeration, useful for initializing arrays or as first argument to map() or foreach() .

The defaults are: step = 1, start = 0, operator = `+

See also

map() , foreach()


Constant __VERSION__

constant __VERSION__

Description

This define contains the current Pike version as a float. If another Pike version is emulated, this define is updated accordingly.

See also

__REAL_VERSION__


Constant __REAL_VERSION__

constant __REAL_VERSION__

Description

This define always contains the version of the current Pike, represented as a float.

See also

__VERSION__


Constant __MAJOR__

constant __MAJOR__

Description

This define contains the major part of the current Pike version, represented as an integer. If another Pike version is emulated, this define is updated accordingly.

See also

__REAL_MAJOR__


Constant __REAL_MAJOR__

constant __REAL_MAJOR__

Description

This define always contains the major part of the version of the current Pike, represented as an integer.

See also

__MAJOR__


Constant __MINOR__

constant __MINOR__

Description

This define contains the minor part of the current Pike version, represented as an integer. If another Pike version is emulated, this define is updated accordingly.

See also

__REAL_MINOR__


Constant __REAL_MINOR__

constant __REAL_MINOR__

Description

This define always contains the minor part of the version of the current Pike, represented as an integer.

See also

__MINOR__


Constant __BUILD__

constant __BUILD__

Description

This constant contains the build number of the current Pike version, represented as an integer. If another Pike version is emulated, this constant remains unaltered.

See also

__REAL_MINOR__


Constant __REAL_BUILD__

constant __REAL_BUILD__

Description

This define always contains the minor part of the version of the current Pike, represented as an integer.

See also

__BUILD__


Constant __LINE__

constant __LINE__

Description

This define contains the current line number, represented as an integer, in the source file.


Constant __FILE__

constant __FILE__

Description

This define contains the file path and name of the source file.


Constant __DATE__

constant __DATE__

Description

This define contains the current date at the time of compilation, e.g. "Jul 28 2001".


Constant __TIME__

constant __TIME__

Description

This define contains the current time at the time of compilation, e.g. "12:20:51".


Constant __PIKE__

constant __PIKE__

Description

This define is always true.


Constant __AUTO_BIGNUM__

constant __AUTO_BIGNUM__

Description

This define is defined when automatic bignum conversion is enabled. When enabled all integers will automatically be converted to bignums when they get bigger than what can be represented by an integer, hampering performance slightly instead of crashing the program.


Constant __NT__

constant __NT__

Description

This define is defined when the Pike is running on a Microsoft Windows OS, not just Microsoft Windows NT, as the name implies.


Constant __amigaos__

constant __amigaos__

Description

This define is defined when the Pike is running on Amiga OS.


Method cpp

string cpp(string data, string|void current_file, int|string|void charset, object|void handler, void|int compat_major, void|int compat_minor)

Description

Run a string through the preprocessor.

Preprocesses the string data with Pike's builtin ANSI-C look-alike preprocessor. If the current_file argument has not been specified, it will default to "-". charset defaults to "ISO-10646".

See also

compile()


Method load_module

program load_module(string module_name)

Description

Load a binary module.

This function loads a module written in C or some other language into Pike. The module is initialized and any programs or constants defined will immediately be available.

When a module is loaded the function pike_module_init() will be called to initialize it. When Pike exits pike_module_exit() will be called. These two functions must be available in the module.

Note

The current working directory is normally not searched for dynamic modules. Please use "./name.so" instead of just "name.so" to load modules from the current directory.


Method encode_value

string encode_value(mixed value, object|void codec)

Description

Code a value into a string.

This function takes a value, and converts it to a string. This string can then be saved, sent to another Pike process, packed or used in any way you like. When you want your value back you simply send this string to decode_value() and it will return the value you encoded.

Almost any value can be coded, mappings, floats, arrays, circular structures etc.

To encode objects, programs and functions, a codec object must be provided.

Note

When only simple types like int, floats, strings, mappings, multisets and arrays are encoded, the produced string is very portable between pike versions. It can at least be read by any later version.

The portability when objects, programs and functions are involved depends mostly on the codec. If the byte code is encoded, i.e. when Pike programs are actually dumped in full, then the string can probably only be read by the same pike version.

See also

decode_value() , sprintf() , encode_value_canonic()


Method encode_value_canonic

string encode_value_canonic(mixed value, object|void codec)

Description

Code a value into a string on canonical form.

Takes a value and converts it to a string on canonical form, much like encode_value() . The canonical form means that if an identical value is encoded, it will produce exactly the same string again, even if it's done at a later time and/or in another Pike process. The produced string is compatible with decode_value() .

Note

Note that this function is more restrictive than encode_value() with respect to the types of values it can encode. It will throw an error if it can't encode to a canonical form.

See also

encode_value() , decode_value()


Method decode_value

mixed decode_value(string coded_value, object|void codec)

Description

Decode a value from a string.

This function takes a string created with encode_value() or encode_value_canonic() and converts it back to the value that was coded.

If no codec is specified, the current master object will be used as codec.

See also

encode_value() , encode_value_canonic()


Method aggregate_mapping

mapping aggregate_mapping(mixed ... elems)

Description

Construct a mapping.

Groups the arguments together two and two in key-index pairs and creates a mapping of those pairs. Generally, the mapping literal syntax is handier:

([ key1:val1, key2:val2, ... ])

See also

sizeof() , mappingp() , mkmapping()


Method aggregate_multiset

multiset aggregate_multiset(mixed ... elems)

Description

Construct a multiset.

Construct a multiset with the arguments as indices. This method is most useful when constructing multisets with map or similar; generally, the multiset literal syntax is handier:

(< elem1, elem2, ... >)

See also

sizeof() , multisetp() , mkmultiset()


Method array_sscanf

array array_sscanf(string data, string format)

Description

This function works just like sscanf() , but returns the matched results in an array instead of assigning them to lvalues. This is often useful for user-defined sscanf strings.

See also

sscanf() , `/()


Method `!=

int(0..1) `!=(mixed arg1, mixed arg2, mixed ... extras)

Description

Inequality operator.

Returns

Returns 0 (zero) if all the arguments are equal, and 1 otherwise.

This is the inverse of `==() .

See also

`==()


Method `==

int(0..1) `==(mixed arg1, mixed arg2, mixed ... extras)

Description

Equality operator.

Returns

Returns 1 if all the arguments are equal, and 0 (zero) otherwise.

See also

`!=()


Method `<

int(0..1) `<(mixed arg1, mixed arg2, mixed ... extras)

Description

Less than operator.

Returns

Returns 1 if the arguments are strictly increasing, and 0 (zero) otherwise.

See also

`<=() , `>() , `>=()


Method `<=

int(0..1) `<=(mixed arg1, mixed arg2, mixed ... extras)

Description

Less or equal operator.

Returns

Returns 1 if the arguments are not strictly decreasing, and 0 (zero) otherwise.

This is the inverse of `>() .

See also

`<() , `>() , `>=()


Method `>

int(0..1) `>(mixed arg1, mixed arg2, mixed ... extras)

Description

Greater than operator.

Returns

Returns 1 if the arguments are strictly decreasing, and 0 (zero) otherwise.

See also

`<() , `<=() , `>=()


Method `>=

int(0..1) `>=(mixed arg1, mixed arg2, mixed ... extras)

Description

Greater or equal operator.

Returns

Returns 1 if the arguments are not strictly increasing, and 0 (zero) otherwise.

This is the inverse of `<() .

See also

`<=() , `>() , `<()


Method `+

mixed `+(mixed arg1)
mixed `+(object arg1, mixed ... extras)
string `+(string arg1, string|int|float arg2)
string `+(int|float arg1, string arg2)
int `+(int arg1, int arg2)
float `+(float arg1, int|float arg2)
float `+(int|float arg1, float arg2)
array `+(array arg1, array arg2)
mapping `+(mapping arg1, mapping arg2)
multiset `+(multiset arg1, multiset arg2)
mixed `+(mixed arg1, mixed arg2, mixed ... extras)

Description

Addition operator.

Returns

If there's only a single argument, that argument will be returned.

If arg1 is an object and it has an lfun::`+() , that function will be called with the rest of the arguments, and the result returned.

Otherwise if any of the other arguments is an object that has an lfun::``+() the first such function will be called with the arguments leading up to it, and `+() be called recursively with the result and the rest of the arguments.

If there are two arguments the result will be:

arg1 can have any of the following types:
string

arg2 will be converted to a string, and the result the strings concatenated.

int|floatarg2 can have any of the following types:
string

arg1 will be converted to string, and the result the strings concatenated.

int|float

The result will be arg1  + arg2 , and will be a float if either arg1 or arg2 is a float.


array

The arrays will be concatenated.

mapping

The mappings will be joined.

multiset

The multisets will be added.


Otherwise if there are more than 2 arguments the result will be:

`+(`+(arg1 , arg2 ), @extras )

Note

In Pike 7.0 and earlier the addition order was unspecified.

If arg1 is UNDEFINED it will behave as the empty array/mapping/multiset if needed. This behaviour was new in Pike 7.0.

See also

`-() , lfun::`+() , lfun::``+()


Method `-

mixed `-(mixed arg1)
mixed `-(object arg1, mixed arg2)
mixed `-(mixed arg1, mixed arg2)
mapping `-(mapping arg1, array arg2)
mapping `-(mapping arg1, multiset arg2)
mapping `-(mapping arg1, mapping arg2)
array `-(array arg1, array arg2)
multiset `-(multiset arg1, multiset arg2)
float `-(float arg1, int|float arg2)
float `-(int arg1, float arg2)
int `-(int arg1, int arg2)
string `-(string arg1, string arg2)
mixed `-(mixed arg1, mixed arg2, mixed ... extras)

Description

Negation/subtraction operator.

Returns

If there's only a single argument, that argument will be returned negated. If arg1 was an object, arg1 ::`-() will be called without arguments.

If there are more than two arguments the result will be:

`-(`-(arg1 , arg2 ), @extras )
.

If arg1 is an object that overloads `-(), that function will be called with arg2 as the single argument.

If arg2 is an object that overloads ``-(), that function will be called with arg1 as the single argument.

Otherwise the result will be as follows:

arg1 can have any of the following types:
mappingarg2 can have any of the following types:
array

The result will be arg1 with all occurrances of arg2 removed.

multiset|mapping

The result will be arg1 with all occurrences of indices (arg2 ) removed.


array|multiset

The result will be the elements of arg1 that are not in arg2 .

float|int

The result will be arg1  - arg2 , and will be a float if either arg1 or arg2 is a float.

string

Result will be the string arg1 with all occurrances of the substring arg2 removed.


Note

In Pike 7.0 and earlier the subtraction order was unspecified.

See also

`+()


Method `&

mixed `&(mixed arg1)
mixed `&(object arg1, mixed arg2)
mixed `&(mixed arg1, object arg2)
int `&(int arg1, int arg2)
array `&(array arg1, array arg2)
multiset `&(multiset arg1, multiset arg2)
mapping `&(mapping arg1, mapping arg2)
string `&(string arg1, string arg2)
type `&(type|program arg1, type|program arg2)
mapping `&(mapping arg1, array arg2)
mapping `&(array arg1, mapping arg2)
mapping `&(mapping arg1, multiset arg2)
mapping `&(multiset arg1, mapping arg2)
mixed `&(mixed arg1, mixed arg2, mixed ... extras)

Description

Bitwise and/intersection operator.

Returns

If there's a single argument, that argument will be returned.

If there are more than two arguments, the result will be:

`&(`&(arg1 , arg2 ), @extras )
.

If arg1 is an object that has an lfun::`&() , that function will be called with arg2 as the single argument.

If arg2 is an object that has an lfun::``&() , that function will be called with arg1 as the single argument.

Otherwise the result will be as follows:

arg1 can have any of the following types:
int

The result will be the bitwise and of arg1 and arg2 .

array|multiset|mapping

The result will be the elements of arg1 and arg2 that occurr in both.

type|program

The result will be the type intersection of arg1 and arg2 .

string

The result will be the string where the elements of arg1 and arg2 have been pairwise bitwise anded.


See also

`|() , lfun::`&() , lfun::``&()


Method `|

mixed `|(mixed arg1)
mixed `|(object arg1, mixed arg2)
mixed `|(mixed arg1, object arg2)
int `|(int arg1, int arg2)
mapping `|(mapping arg1, mapping arg2)
multiset `|(multiset arg1, multiset arg2)
array `|(array arg1, array arg2)
string `|(string arg1, atring arg2)
type `|(program|type arg1, program|type arg2)
mixed `|(mixed arg1, mixed arg2, mixed ... extras)

Description

Bitwise or/join operator.

Returns

If there's a single argument, that argument will be returned.

If there are more than two arguments, the result will be:

`|(`|(arg1 , arg2 ), @extras )
.

If arg1 is an object that has an lfun::`|() , that function will be called with arg2 as the single argument.

If arg2 is an object that has an lfun::``|() , that function will be called with arg1 as the single argument.

Otherwise the result will be as follows:

arg1 can have any of the following types:
int

The result will be the binary or of arg1 and arg2 .

mapping|multiset

The result will be the join of arg1 and arg2 .

array

The result will be the concatenation of arg1 and arg2 .

string

The result will be the pairwise bitwose or of arg1 and arg2 .

type|program

The result will be the type join of arg1 and arg2 .


See also

`&() , lfun::`|() , lfun::``|()


Method `^

mixed `^(mixed arg1)
mixed `^(object arg1, mixed arg2)
mixed `^(mixed arg1, object arg2)
int `^(int arg1, int arg2)
mapping `^(mapping arg1, mapping arg2)
multiset `^(multiset arg1, multiset arg2)
array `^(array arg1, array arg2)
string `^(string arg1, atring arg2)
type `^(program|type arg1, program|type arg2)
mixed `^(mixed arg1, mixed arg2, mixed ... extras)

Description

Exclusive or operator.

Returns

If there's a single argument, that argument will be returned.

If there are more than two arguments, the result will be:

`^(`^(arg1 , arg2 ), @extras )
.

If arg1 is an object that has an lfun::`^() , that function will be called with arg2 as the single argument.

If arg2 is an object that has an lfun::``^() , that function will be called with arg1 as the single argument.

Otherwise the result will be as follows:

arg1 can have any of the following types:
int

The result will be the bitwise xor of arg1 and arg2 .

mapping|multiset|array

The result will be the elements of arg1 and arg2 that only occurr in one of them.

string

The result will be the pairwise bitwise xor of arg1 and arg2 .

type|program

The result will be the result of (arg1 &~arg2 )|(~arg1 &arg2 ).


See also

`&() , `|() , lfun::`^() , lfun::``^()


Method `<<

int `<<(int arg1, int arg2)
mixed `<<(object arg1, int|object arg2)
mixed `<<(int arg1, object arg2)

Description

Left shift operator.

If arg1 is an object that implements lfun::`<<() , that function will be called with arg2 as the single argument.

If arg2 is an object that implements lfun::``<<() , that function will be called with arg1 as the single argument.

Otherwise arg1 will be shifted arg2 bits left.

See also

`>>()


Method `>>

int `>>(int arg1, int arg2)
mixed `>>(object arg1, int|object arg2)
mixed `>>(int arg1, object arg2)

Description

Right shift operator.

If arg1 is an object that implements lfun::`>>() , that function will be called with arg2 as the single argument.

If arg2 is an object that implements lfun::``>>() , that function will be called with arg1 as the single argument.

Otherwise arg1 will be shifted arg2 bits right.

See also

`<<()


Method `*

mixed `*(mixed arg1)
mixed `*(object arg1, mixed arg2, mixed ... extras)
mixed `*(mixed arg1, object arg2)
array `*(array arg1, int arg2)
array `*(array arg1, float arg2)
string `*(string arg1, int arg2)
string `*(string arg1, float arg2)
string `*(array(string) arg1, string arg2)
array `*(array(array) arg1, array arg2)
float `*(float arg1, int|float arg2)
float `*(int arg1, float arg2)
int `*(int arg1, int arg2)
mixed `*(mixed arg1, mixed arg2, mixed ... extras)

Description

Multiplication operator.

Returns

If there's only a single argument, that argument will be returned.

If the first argument is an object that implements lfun::`*() , that function will be called with the rest of the arguments.

If there are more than two arguments, the result will be `*(`*(arg1 , arg2 ), @extras ).

If arg2 is an object that implements lfun::``*() , that function will be called with arg1 as the single argument.

Otherwise the result will be as follows:

arg1 can have any of the following types:
arrayarg2 can have any of the following types:
int|float

The result will be arg1 concatenated arg2 times.

string|array

The result will be the elements of arg1 concatenated with arg2 interspersed.


string

The result will be arg1 concatenated arg2 times.

int|float

The result will be arg1  * arg2 , and will be a float if either arg1 or arg2 is a float.


Note

In Pike 7.0 and earlier the multiplication order was unspecified.

See also

`+() , `-() , `/() , lfun::`*() , lfun::``*()


Method `/

mixed `/(object arg1, mixed arg2)
mixed `/(mixed arg1, object arg2)
array(string) `/(string arg1, int arg2)
array(string) `/(string arg1, float arg2)
array(array) `/(array arg1, int arg2)
array(array) `/(array arg1, float arg2)
array(string) `/(string arg1, atring arg2)
array(array) `/(array arg1, array arg2)
float `/(float arg1, int|float arg2)
float `/(int arg1, float arg2)
int `/(int arg1, int arg2)
mixed `/(mixed arg1, mixed arg2, mixed ... extras)

Description

Division operator.

Returns

If there are more than two arguments, the result will be `/(`/(arg1 , arg2 ), @extras ).

If arg1 is an object that implements lfun::`/() , that function will be called with arg2 as the single argument.

If arg2 is an object that implements lfun::``/() , that function will be called with arg1 as the single argument.

Otherwise the result will be as follows:

arg1 can have any of the following types:
stringarg2 can have any of the following types:
int|float

The result will be and array of arg1 split in segments of length arg2 . If arg2 is negative the splitting will start from the end of arg1 .

string

The result will be an array of arg1 split at each occurrence of arg2 . Note that the segments that matched against arg2 will not be in the result.


arrayarg2 can have any of the following types:
int|float

The result will be and array of arg1 split in segments of length arg2 . If arg2 is negative the splitting will start from the end of arg1 .

array

The result will be an array of arg1 split at each occurrence of arg2 . Note that the elements that matched against arg2 will not be in the result.


float|int

The result will be arg1  / arg2 . If both arguments are int, the result will be truncated to an int. Otherwise the result will be a float.



Method `%

mixed `%(object arg1, mixed arg2)
mixed `%(mixed arg1, object arg2)
string `%(string arg1, int arg2)
array `%(array arg1, int arg2)
float `%(float arg1, float|int arg2)
float `%(int arg1, float arg2)
int `%(int arg1, int arg2)

Description

Modulo operator.

Returns

If arg1 is an object that implements lfun::`%() then that function will be called with arg2 as the single argument.

If arg2 is an object that implements lfun::``%() then that function will be called with arg2 as the single argument.

Otherwise the result will be as follows:

arg1 can have any of the following types:
string|array

If arg2 is positive, the result will be the last `%(sizeof (arg1 ), arg2 ) elements of arg1 . If arg2 is negative, the result will be the first `%(sizeof (arg1 ), -arg2 ) elements of arg1 .

int|float

The result will be arg1  - arg2 *floor (arg1 /arg2 ). The result will be a float if either arg1 or arg2 is a float, and an int otherwise.



Method `!

int(0..1) `!(object|function arg)
int(1..1) `!(int(0..0) arg)
int(0..0) `!(mixed arg)

Description

Negation operator.

Returns

If arg is an object that implements lfun::`!() , that function will be called.

If arg is 0 (zero), a destructed object, or a function in a destructed object, 1 will be returned.

Otherwise 0 (zero) will be returned.

See also

`==() , `!=() , lfun::`!()


Method `~

mixed `~(object arg)
int `~(int arg)
float `~(float arg)
type `~(type|program arg)
string `~(string arg)

Description

Complement operator.

Returns

The result will be as follows:

arg can have any of the following types:
object

If arg implements lfun::`~() , that function will be called.

int

The bitwise inverse of arg will be returned.

float

The result will be -1.0 - arg .

type|program

The type inverse of arg will be returned.

string

If arg only contains characters in the range 0 - 255 (8-bit), a string containing the corresponding 8-bit inverses will be returned.


See also

`!() , lfun::`~()


Method `[]

mixed `[](object arg, mixed index)
mixed `[](object arg, string index)
mixed `[](int arg, string index)
mixed `[](array arg, int index)
mixed `[](array arg, mixed index)
mixed `[](mapping arg, mixed index)
int(0..1) `[](multiset arg, mixed index)
int `[](string arg, int index)
mixed `[](program arg, string index)
mixed `[](object arg, mixed start, mixed end)
string `[](string arg, int start, int end)
array `[](array arg, int start, int end)

Description

Index and range operator.

Returns

If arg is an object that implements lfun::`[]() , that function will be called with the rest of the arguments.

If there are 2 arguments the result will be as follows:

arg can have any of the following types:
object

The non-static (ie public) symbol named index will be looked up in arg .

int

The bignum function named index will be looked up in arg .

array

If index is an int, index number index of arg will be returned. Otherwise an array of all elements in arg indexed with index will be returned.

mapping

If index exists in arg the corresponding value will be returned. Otherwise UNDEFINED will be returned.

multiset

If index exists in arg , 1 will be returned. Otherwise UNDEFINED will be returned.

string

The character (int) at index index in arg will be returned.

program

The non-static (ie public) constant symbol index will be looked up in arg .


Otherwise if there are 3 arguments the result will be as follows:

arg can have any of the following types:
string

A string with the characters between start and end (inclusive) in arg will be returned.

array

An array with the elements between start and end (inclusive) in arg will be returned.


See also

`->() , lfun::`[]()


Method `->

mixed `->(object arg, string index)
mixed `->(int arg, string index)
mixed `->(array arg, string index)
mixed `->(mapping arg, string index)
int(0..1) `->(multiset arg, string index)
mixed `->(program arg, string index)

Description

Arrow index operator.

This function behaves much like `[]() , just that the index is always a string.

Returns

If arg is an object that implements lfun::`->() , that function will be called with index as the single argument.

Otherwise the result will be as follows:

arg can have any of the following types:
object

The non-static (ie public) symbol named index will be looked up in arg .

int

The bignum function named index will be looked up in arg .

array

An array of all elements in arg arrow indexed with index will be returned.

mapping

If index exists in arg the corresponding value will be returned. Otherwise UNDEFINED will be returned.

multiset

If index exists in arg , 1 will be returned. Otherwise UNDEFINED will be returned.

program

The non-static (ie public) constant symbol index will be looked up in arg .


See also

`[]() , lfun::`->() , ::`->()


Method `[]=

mixed `[]=(object arg, mixed index, mixed val)
mixed `[]=(object arg, string index, mixed val)
mixed `[]=(array arg, int index, mixed val)
mixed `[]=(mapping arg, mixed index, mixed val)
int(0..1) `[]=(multiset arg, mixed index, int(0..1) val)

Description

Index assign operator.

If arg is an object that implements lfun::`[]=() , that function will be called with index and val as the arguments.

arg can have any of the following types:
object

The non-static (ie public) variable named index will be looked up in arg , and assigned val .

array|mapping

Index index in arg will be assigned val .

multiset

If val is 0 (zero), one occurrance of index in arg will be removed. Otherwise index will be added to arg if it is not already there.


Returns

val will be returned.

See also

`->=() , lfun::`[]=()


Method `->=

mixed `->=(object arg, string index, mixed val)
mixed `->=(mapping arg, string index, mixed val)
int(0..1) `->=(multiset arg, string index, int(0..1) val)

Description

Arrow assign operator.

This function behaves much like `[]=() , just that the index is always a string.

If arg is an object that implements lfun::`->=() , that function will be called with index and val as the arguments.

arg can have any of the following types:
object

The non-static (ie public) variable named index will be looked up in arg , and assigned val .

array|mapping

Index index in arg will be assigned val .

multiset

If val is 0 (zero), one occurrance of index in arg will be removed. Otherwise index will be added to arg if it is not already there.


Returns

val will be returned.

See also

`[]=() , lfun::`->=()


Method sizeof

int sizeof(string arg)
int sizeof(array arg)
int sizeof(mapping arg)
int sizeof(multiset arg)
int sizeof(object arg)

Description

Sizeof operator.

Returns

The result will be as follows:

arg can have any of the following types:
string

The number of characters in arg will be returned.

array|multiset

The number of elements in arg will be returned.

mapping

The number of key-value pairs in arg will be returned.

object

If arg implements lfun::_sizeof() , that function will be called. Otherwise the number of non-static (ie public) symbols in arg will be returned.


See also

lfun::_sizeof()


Constant UNDEFINED

constant UNDEFINED

Description

The undefined value; ie a zero for which zero_type() returns 1.


Constant this

constant this

Description

Builtin read only variable that evaluates to the current object.

See also

this_program , this_object()


Constant this_program

constant this_program

Description

Builtin constant that evaluates to the current program.

See also

this , this_object()


Method signal

void signal(int sig, function(int:void) callback)
void signal(int sig)

Description

Trap signals.

This function allows you to trap a signal and have a function called when the process receives a signal. Although it IS possible to trap SIGBUS, SIGSEGV etc. I advice you not to. Pike should not receive any such signals and if it does it is because of bugs in the Pike interpreter. And all bugs should be reported, no matter how trifle.

The callback will receive the signal number as its only argument.

See the documentation for kill() for a list of signals.

If no second argument is given, the signal handler for that signal is restored to the default handler.

If the second argument is zero, the signal will be completely ignored.

See also

kill() , signame() , signum()


Method signum

int signum(string sig)

Description

Get a signal number given a descriptive string.

This function is the inverse of signame() .

See also

signame() , kill() , signal()


Method signame

string signame(int sig)

Description

Returns a string describing the signal sig .

See also

kill() , signum() , signal()


Method set_priority

int set_priority(string level, int|void pid)


Method fork

int fork()

Description

Fork the process in two.

Fork splits the process in two, and for the parent it returns the pid of the child. Refer to your Unix manual for further details.

Note

This function can cause endless bugs if used without proper care.

This function is disabled when using threads.

This function is not available on all platforms.

The most common use for fork is to start sub programs, which is better done with Process.create_process() .

See also

Process.create_process()


Method kill

void kill(int pid, int signal)

Description

Send a signal to another process. Returns nonzero if it worked, zero otherwise. errno may be used in the latter case to find out what went wrong.

Some signals and their supposed purpose:

SIGHUP

Hang-up, sent to process when user logs out.

SIGINT

Interrupt, normally sent by ctrl-c.

SIGQUIT

Quit, sent by ctrl-\.

SIGILL

Illegal instruction.

SIGTRAP

Trap, mostly used by debuggers.

SIGABRT

Aborts process, can be caught, used by Pike whenever something goes seriously wrong.

SIGEMT

Emulation trap.

SIGFPE

Floating point error (such as division by zero).

SIGKILL

Really kill a process, cannot be caught.

SIGBUS

Bus error.

SIGSEGV

Segmentation fault, caused by accessing memory where you shouldn't. Should never happen to Pike.

SIGSYS

Bad system call. Should never happen to Pike.

SIGPIPE

Broken pipe.

SIGALRM

Signal used for timer interrupts.

SIGTERM

Termination signal.

SIGUSR1

Signal reserved for whatever you want to use it for. Note that some OSs reserve this signal for the thread library.

SIGUSR2

Signal reserved for whatever you want to use it for. Note that some OSs reserve this signal for the thread library.

SIGCHLD

Child process died. This signal is reserved for internal use by the Pike run-time.

SIGPWR

Power failure or restart.

SIGWINCH

Window change signal.

SIGURG

Urgent socket data.

SIGIO

Pollable event.

SIGSTOP

Stop (suspend) process.

SIGTSTP

Stop (suspend) process. Sent by ctrl-z.

SIGCONT

Continue suspended.

SIGTTIN

TTY input for background process.

SIGTTOU

TTY output for background process.

SIGVTALRM

Virtual timer expired.

SIGPROF

Profiling trap.

SIGXCPU

Out of CPU.

SIGXFSZ

File size limit exceeded.

SIGSTKFLT

Stack fault


Note

Note that you have to use signame to translate the name of a signal to its number.

Note that the kill function is not available on platforms that do not support signals. Some platforms may also have signals not listed here.

See also

signal() , signum() , signame() , fork()


Method getpid

int getpid()

Description

Returns the process ID of this process.

See also

System.getppid() , System.getpgrp()


Method alarm

int alarm(int seconds)

Description

Set an alarm clock for delivery of a signal.

alarm() arranges for a SIGALRM signal to be delivered to the process in seconds seconds.

If seconds is 0 (zero), no new alarm will be scheduled.

Any previous alarms will in any case be canceled.

Returns

Returns the number of seconds remaining until any previously scheduled alarm was due to be delivered, or zero if there was no previously scheduled alarm.

Note

This function is only available on platforms that support signals.

See also

ualarm() , signal() , call_out()


Method ualarm

int ualarm(int useconds)

Description

Set an alarm clock for delivery of a signal.

alarm() arranges for a SIGALRM signal to be delivered to the process in useconds microseconds.

If useconds is 0 (zero), no new alarm will be scheduled.

Any previous alarms will in any case be canceled.

Returns

Returns the number of microseconds remaining until any previously scheduled alarm was due to be delivered, or zero if there was no previously scheduled alarm.

Note

This function is only available on platforms that support signals.

See also

alarm() , signal() , call_out()


Method atexit

void atexit(function callback)

Description

This function puts the callback in a queue of callbacks to call when pike exits.

Note

Please note that atexit callbacks are not called if Pike exits abnormally.

See also

exit() , _exit()


Method _disable_threads

_disable_threads _disable_threads()

Description

This function first posts a notice to all threads that it is time to stop. It then waits until all threads actually *have* stopped, and then then returns a lock object. All other threads will be blocked from running until that object has been freed/destroyed.

It's mainly useful to do things that require a temporary uid/gid change, since on many OS the effective user and group applies to all threads.

Note

You should make sure that the returned object is freed even if some kind of error is thrown. That means in practice that it should only have references (direct or indirect) from function local variables. Also, it shouldn't be referenced from cyclic memory structures, since those are only destructed by the periodic gc. (This advice applies to mutex locks in general, for that matter.)


Method call_function

mixed call_function(function fun, mixed ... args)

Description

Call a function.


Method version

string version()

Description

Report the version of Pike.

See also

__VERSION__ , __MINOR__ , __BUILD__ , __REAL_VERSION__ , __REAL_MINOR__ , __REAL_BUILD__ ,


Method call_out
Method _do_call_outs
Method find_call_out
Method remove_call_out
Method call_out_info

mixed call_out(function f, float|int delay, mixed ... args)
void _do_call_outs()
int find_call_out(function f)
int find_call_out(mixed id)
int remove_call_out(function f)
int remove_call_out(function id)
array(array) call_out_info()

Description

These are aliases for the corresponding functions in Pike.DefaultBackend .

See also

Pike.Backend()->call_out() , Pike.Backend()->_do_call_outs() , Pike.Backend()->find_call_out() , Pike.Backend()->remove_call_out() , Pike.Backend()->call_out_info()


Method basetype

string basetype(mixed x)

Description

Same as sprintf("%t",x);

See also

sprintf()


Method column

array column(array data, mixed index)

Description

Extract a column from a two-dimensional array.

This function is exactly equivalent to:

map(data , lambda(mixed x,mixed y) { return x[y]; }, index )

Except of course it is a lot shorter and faster. That is, it indices every index in the array data on the value of the argument index and returns an array with the results.

See also

rows()


Method mkmultiset

multiset mkmultiset(array a)

Description

This function creates a multiset from an array.

See also

aggregate_multiset()


Method trace

int trace(int t)

Description

This function changes the debug trace level.

The old level is returned.

Trace level 1 or higher means that calls to Pike functions are printed to stderr, level 2 or higher means calls to builtin functions are printed, 3 means every opcode interpreted is printed, 4 means arguments to these opcodes are printed as well.

See the -t command-line option for more information.


Method ctime

string ctime(int timestamp)

Description

Convert the output from a previous call to time() into a readable string containing the current year, month, day and time.

Like localtime , this function might throw an error if the ctime(2) call failed on the system. It's platform dependent what time ranges that function can handle, e.g. Windows doesn't handle a negative timestamp .

See also

time() , localtime() , mktime() , gmtime()


Method mkmapping

mapping mkmapping(array ind, array val)

Description

Make a mapping from two arrays.

Makes a mapping ind[x] :val[x] , 0 <= x < sizeof(ind).

ind and val must have the same size.

This is the inverse operation of indices() and values() .

See also

indices() , values()


Method m_delete

mixed m_delete(object|mapping map, mixed index)

Description

If map is an object that implements lfun::_m_delete() , that function will be called with index as the signle argument.

Other wise if map is a mapping the entry with index index will be removed from map destructively.

If the mapping does not have an entry with index index , nothing is done.

Returns

The value that was removed will be returned.

Note

Note that m_delete() changes map destructively.

See also

mappingp()


Method get_weak_flag

int get_weak_flag(array|mapping|multiset m)

Description

Returns the weak flag settings for m . It's a combination of Pike.WEAK_INDICES and Pike.WEAK_VALUES .


Method function_name

string function_name(function f)

Description

Return the name of the function f .

If f is a global function defined in the runtime 0 (zero) will be returned.

See also

function_object()


Method function_object

object function_object(function f)

Description

Return the object the function f is in.

If f is a global function defined in the runtime 0 (zero) will be returned.

Zero will also be returned if f is a constant in the parent class. In that case function_program() can be used to get the parent program.

See also

function_name() , function_program()


Method function_program

program function_program(function|program f)

Description

Return the program the function f is in.

If f is a global function defined in the runtime 0 (zero) will be returned.

See also

function_name() , function_object()


Method random

int random(int max)

Description

This function returns a random number in the range 0 - max -1.

See also

random_seed()


Method backtrace

array(Pike.BacktraceFrame) backtrace()

Description

FIXME: This documentation is not up to date!

Get a description of the current call stack.

The description is returned as an array with one entry for each call frame on the stack.

Each entry has this format:

Array
string file

A string with the filename if known, else zero.

int line

An integer containing the linenumber if known, else zero.

function fun

The function that was called at this level.

mixed|void ... args

The arguments that the function was called with.


The current call frame will be last in the array.

Note

Please note that the frame order may be reversed in a later version (than 7.1) of Pike to accomodate for deferred backtraces.

Note that the arguments reported in the backtrace are the current values of the variables, and not the ones that were at call-time. This can be used to hide sensitive information from backtraces (eg passwords).

See also

catch() , throw()


Method error

void error(string f, mixed ... args)

Description

Throws an error. A more readable version of the code throw( ({ sprintf(f, @args), backtrace() }) ).


Method is_absolute_path

int is_absolute_path(string p)

Description

Check if a path p is fully qualified (ie not relative).

Returns

Returns 1 if the path is absolute, 0 otherwise.


Method explode_path

array(string) explode_path(string p)

Description

Split a path p into its components.

This function divides a path into its components. This might seem like it could be done by dividing the string on <tt>"/"</tt>, but that will not work on some operating systems.


Method dirname

string dirname(string x)

Description

Returns all but the last segment of a path. Some example inputs and outputs:

ExpressionValue
dirname("/a/b")"/a/"
dirname("/a/")"/a/"
dirname("/a")"/"
dirname("/")"/"
dirname("")""

See also

basename() , explode_path()


Method basename

string basename(string x)

Description

Returns the last segment of a path.

See also

dirname() , explode_path()


Method compile_string

program compile_string(string source, void|string filename, object|void handler)

Description

Compile the Pike code in the string source into a program. If filename is not specified, it will default to "-".

Functionally equal to

compile (cpp (source , filename ))
.

See also

compile() , cpp() , compile_file()


Method getenv

string getenv(string varname)
mapping(string:string) getenv()

Description

When called with no arguments, a mapping with all current environment variables will be returned. Destructive opreations on the mapping will not affect the internal environment representation.

If the varname argument has been given, the value of the environment variable with the name varname will be returned. If no such environment variable exists, 0 (zero) will be returned.

On NT the environment variable name is case insensitive.


Method compile_file

program compile_file(string filename, object|void handler, void|program p, void|object o)

Description

Compile the Pike code contained in the file filename into a program.

This function will compile the file filename to a Pike program that can later be instantiated. It is the same as doing

compile_string (Stdio.read_file (filename ), filename )
.

See also

compile() , compile_string() , cpp()


Method putenv

void putenv(string varname, string value)

Description

Sets the environment variable varname to value .

On NT the environment variable name is case insensitive.

See also

getenv()


Method normalize_path

string normalize_path(string path)

Description

Replaces "\" with "/" if runing on MS Windows. It is adviced to use System.normalize_path instead.


Method describe_backtrace

string describe_backtrace(mixed trace, void|int linewidth)

Description

Returns a string containing a readable message that describes where the backtrace was made.

The argument trace should normally be the return value from a call to backtrace() , or a caught error.

See also

backtrace() , describe_error() , catch() , throw()


Method describe_error

string describe_error(mixed trace)

Description

Returns only the error message from a backtrace.

If there is no error message in the backtrace, a fallback message will be returned.

See also

backtrace() , describe_backtrace()

  CLASS Error


Method cast

array cast(string type)

Description

Cast operator.

Note

The only supported type to cast to is "array", which generates and old-style error.


Method `[]

array|string `[](int(0..1) index)

Description

Index operator.

Simulates an array

Array
string msg

Error message.

array backtrace

Backtrace as returned by backtrace() from where the error occurred.


Note

The error message is always terminated with a newline.

See also

backtrace()


Method describe

string describe()

Description

Make a readable error-message.

Note

Uses describe_backtrace() to generate the message.


Method backtrace

array backtrace()

Description

Get the backtrace from where the error occurred.

See also

predef::backtrace()


Method _sprintf

string _sprintf()


Method create

void Error(string message)

  CLASS string_assignment


Method `[]

int `[](int i, int j)

Description

String index operator.


Method `[]=

int `[]=(int i, int j)

Description

String assign index operator.

  CLASS master


Inherit CompatResolver

inherit CompatResolver : CompatResolver


Constant bt_max_string_len

constant bt_max_string_len

Description

This constant contains the maximum length of a function entry in a backtrace. Defaults to 200 if no BT_MAX_STRING_LEN define has been given.


Constant out_of_date_warning

constant out_of_date_warning

Description

Should Pike complain about out of date compiled files. 1 means yes and 0 means no. Controlled by the OUT_OF_DATE_WARNING define.


Variable want_warnings

int want_warnings

Description

If not zero compilation warnings will be written out on stderr.


Variable compat_major

int compat_major


Variable compat_minor

int compat_minor


Method master_read_file

string master_read_file(string file)


Method cast_to_program

program cast_to_program(string pname, string current_file, object|void handler)

Description

This function is called when the driver wants to cast a string to a program, this might be because of an explicit cast, an inherit or a implict cast. In the future it might receive more arguments, to aid the master finding the right program.


Method handle_error

void handle_error(array(mixed)|object trace)

Description

This function is called when an error occurs that is not caught with catch().


Method handle_inherit

program handle_inherit(string pname, string current_file, object|void handler)

Description

This function is called whenever a inherit is called for. It is supposed to return the program to inherit. The first argument is the argument given to inherit, and the second is the file name of the program currently compiling. Note that the file name can be changed with #line, or set by compile_string, so it can not be 100% trusted to be a filename. previous_object(), can be virtually anything in this function, as it is called from the compiler.


Method cast_to_object

object cast_to_object(string oname, string current_file)

Description

This function is called when the drivers wants to cast a string to an object because of an implict or explicit cast. This function may also receive more arguments in the future.


string _pike_file_name
string _master_file_name

Description

These are useful if you want to start other Pike processes with the same options as this one was started with.


Method asyncp

int(0..1) asyncp()

Description

Returns 1 if we´re in async-mode, e.g. if the main method has returned a negative number.


Method backend_thread

object backend_thread()

Description

The backend_thread() function is useful to determine if you are the backend thread - important when doing async/sync protocols. This method is only available if thread_create is present.


Method _main

void _main(array(string) orig_argv, array(string) env)

Description

This function is called when all the driver is done with all setup of modules, efuns, tables etc. etc. and is ready to start executing _real_ programs. It receives the arguments not meant for the driver and an array containing the environment variables on the same form as a C program receives them.


Method compile_error

void compile_error(string file, int line, string err)

Description

This function is called whenever a compiling error occurs. Nothing strange about it. Note that previous_object cannot be trusted in ths function, because the compiler calls this function.


Method compile_warning

void compile_warning(string file, int line, string err)

Description

This function is called whenever a compiling warning occurs. Nothing strange about it. Note that previous_object cannot be trusted in ths function, because the compiler calls this function.


Method compile_exception

int compile_exception(array|object trace)

Description

This function is called when an exception is catched during compilation. Its message is also reported to compile_error if this function returns zero.


Method runtime_warning

void runtime_warning(string where, string what, mixed ... args)

Description

Called for every runtime warning. The first argument identifies where the warning comes from, the second identifies the specific message, and the rest depends on that. See code below for currently implemented warnings.


Method decode_charset

string decode_charset(string data, string charset)

Description

This function is called by cpp() when it wants to do character code conversion.


Method describe_module

string describe_module(object|program mod, array(object)|void ret_obj)

Description

Describe the path to the module mod .

Parameter mod

If mod is a program, attempt to describe the path to a clone of mod .

Parameter ret_obj

If an instance of mod is found, it will be returned by changing element 0 of ret_obj .

Returns

The a description of the path.

Note

The returned description will end with a proper indexing method currently either "." or "->".


Method describe_object

string describe_object(object|program o)


Method describe_program

string describe_program(program p)


Method describe_function

string describe_function(function f)


Variable currentversion

Version currentversion

Description

Version information about the current Pike version.

  CLASS master.CompatResolver


Method create

void master.CompatResolver(mixed version)

Description

The CompatResolver is initialized with a value that can be casted into a "%d.%d" string, e.g. a version object.


Method add_include_path

void add_include_path(string tmp)

Description

Add a directory to search for include files.

This is the same as the command line option -I.

Note

Note that the added directory will only be searched when using < > to quote the included file.

See also

remove_include_path()


Method remove_include_path

void remove_include_path(string tmp)

Description

Remove a directory to search for include files.

This function performs the reverse operation of add_include_path() .

See also

add_include_path()


Method add_module_path

void add_module_path(string tmp)

Description

Add a directory to search for modules.

This is the same as the command line option -M.

See also

remove_module_path()


Method remove_module_path

void remove_module_path(string tmp)

Description

Remove a directory to search for modules.

This function performs the reverse operation of add_module_path() .

See also

add_module_path()


Method add_program_path

void add_program_path(string tmp)

Description

Add a directory to search for programs.

This is the same as the command line option -P.

See also

remove_program_path()


Method remove_program_path

void remove_program_path(string tmp)

Description

Remove a directory to search for programs.

This function performs the reverse operation of add_program_path() .

See also

add_program_path()


Method add_predefine

void add_predefine(string name, string value)

Description

Add a define (without arguments) which will be implicitly defined in cpp calls.


Method remove_predefine

void remove_predefine(string name)

Description

Remove a define from the set that are implicitly defined in cpp calls.


Method get_predefines

mapping get_predefines()

Description

Returns a mapping with the current predefines.


Method get_default_module

mapping get_default_module()


Method resolv_base

mixed resolv_base(string identifier, string|void current_file, object|void current_handler)


Method resolv

mixed resolv(string identifier, string|void current_file, object|void current_handler)


Method handle_include

string handle_include(string f, string current_file, int local_include)

Description

This function is called whenever an #include directive is encountered it receives the argument for #include and should return the file name of the file to include


Method read_include

string read_include(string f)

  CLASS master.Version

Description

Contains version information about a Pike version.


int major
int minor

Description

The major and minor parts of the version.


Method create

void master.Version(int major, int minor)

Description

Set the version in the object.


Method `<
Method `>
Method `==
Method _hash

int `<(Version v)
int `>(Version v)
int `==(Version v)
int _hash()

Description

Methods define so that version objects can be compared and ordered.


Method cast

mixed cast(string type)

Description

The version object can be casted into a string.

  Module SDL

Description

SDL or Simple DirectMedia Layer is a cross-platform multimedia library designed to provide fast access to the graphics framebuffer, audio device, input and other devices. This module implements a wrapper for SDL and other relevant libraries like SDL_mixer. The interface is similar to the C one, but using generally accepted Pike syntax.

This means that classes are used when appropriate and that method names use all lowercase letters with words separated by _. For example SDL_SetVideoMode is named SDL.set_video_mode. Also note that unless otherwise noted, errors result in an error being thrown rather than returning -1 or 0, as commonly done in SDL methods.


Method init

void SDL.init(int flags)

Description

Initializes SDL. This should be called before all other SDL functions.

Parameter flags

The flags parameter specifies what part(s) of SDL to initialize. It can be one of many of the following ORed together.

SDL.INIT_TIMER

Initializes the timer subsystem.

SDL.INIT_AUDIO

Initializes the audio subsystem.

SDL.INIT_VIDEO

Initializes the video subsystem.

SDL.INIT_CDROM

Initializes the cdrom subsystem.

SDL.INIT_JOYSTICK

Initializes the joystick subsystem.

SDL.INIT_EVERYTHING

Initialize all of the above.

SDL.INIT_NOPARACHUTE

Prevents SDL from catching fatal signals.

SDL.INIT_EVENTTHREAD

Run event polling in a separate thread. Not always supported.

See also

SDL.quit() , SDL.init_sub_system() , SDL.quit_sub_system()


Method get_error

void|string SDL.get_error()

Description

Get the last internal SDL error.

Returns

The error string, or zero if there was no error.


Method init_sub_system

void SDL.init_sub_system(int flags)

Description

After SDL has been initialized with init() you may initialize uninitialized subsystems with this method.

Parameter flags

The same as what is used in SDL.init() .


Method init_sub_system

void SDL.init_sub_system(int flags)

Description

After SDL has been initialized with SDL.init() you may initialize uninitialized subsystems with this method.

Parameter flags

a bitwise OR'd combination of the subsystems you wish to check (see SDL.init() for a list of subsystem flags).

See also

SDL.init() , SDL.quit() , SDL.quit_sub_system()


Method was_init

int SDL.was_init(int flags)

Description

This method allows you to see which SDL subsytems have been initialized.

Parameter flags

a bitwise OR'd combination of the subsystems you wish to check (see SDL.init() for a list of subsystem flags).

Returns

a bitwised OR'd combination of the initialized subsystems

See also

SDL.init() , SDL.init_sub_system()


Method quit

void SDL.quit()

Description

Shuts down all SDL subsystems and frees the resources allocated to them. This should always be called before you exit.

Note

You can use the atexit() method to ensure that this method is always called when Pike exits normally.

See also

SDL.init() , SDL.init_sub_system() , SDL.quit_sub_system()


Method enable_unicode

int SDL.enable_unicode(int enable)

Description

Enables/Disables UNICODE keyboard translation.

If you wish to translate a keysym to it's printable representation, you need to enable UNICODE translation using this function and then look in the unicode member of the SDL.Keysym class. This value will be zero for keysyms that do not have a printable representation. UNICODE translation is disabled by default as the conversion can cause a slight overhead.

Parameter enable

A value of 1 enables Unicode translation, 0 disables it and -1 leaves it unchanged (useful for querying the current translation mode).

Returns

The previous translation mode (1 enabled, 0 disabled). If enable is -1, the return value is the current translation mode.

See also

SDL.Keysym


Method get_mod_state

int SDL.get_mod_state()

Description

Returns the current state of the modifier keys (CTRL, ALT, etc.).

Returns

The return value can be an OR'd combination of the following: SDL.KMOD_NONE, SDL.KMOD_LSHIFT, SDL.KMOD_RSHIFT, SDL.KMOD_LCTRL, SDL.KMOD_RCTRL, SDL.KMOD_LALT, SDL.KMOD_RALT, SDL.KMOD_LMETA, SDL.KMOD_RMETA, SDL.KMOD_NUM, SDL.KMOD_CAPS, and SDL.KMOD_MODE. For convenience the following are also defined: SDL.KMOD_CTRL, SDL.KMOD_SHIFT, SDL.KMOD_ALT and SDL.KMOD_META

See also

SDL.get_key_state()


Method get_key_state

string SDL.get_key_state()

Description

Gets a snapshot of the current keyboard state. The current state is return as a string. The string is indexed by the SDL.K_* symbols. A value of 1 means the key is pressed and a value of 0 means its not.

Note

SDL.pump_events() to update the state array.


Method flip

int SDL.flip(SDL.Surface|void screen)

Description

On hardware that supports double-buffering, this function sets up a flip and returns. The hardware will wait for vertical retrace, and then swap video buffers before the next video surface blit or lock will return. On hardware that doesn't support double-buffering, this is equivalent to calling SDL.update_rect(screen, 0, 0, 0, 0)

The SDL.DOUBLEBUF flag must have been passed to SDL_SetVideoMode, when setting the video mode for this function to perform hardware flipping.

Parameter screen

The screen object to flip. If missing, the default screen is used.

Returns

This function returns 1 if successful, or 0 if there was an error.

See also

SDL.update_rect()


Method update_rect

void SDL.update_rect(int x, int y, int w, int h, SDL.Surface|void screen)

Description

Makes sure the given area is updated on the given screen. The rectangle must be confined within the screen boundaries (no clipping is done).

If 'x', 'y', 'w' and 'h' are all 0, SDL_UpdateRect will update the entire screen.

This function should not be called while 'screen' is locked.

Parameter x
Parameter y

Top left corner of the rectangle to update.

Parameter w
Parameter h

Width and height of the rectangle to update.

Parameter screen

The screen object to flip. If missing, the default screen is used.

See also

SDL.flip()

  CLASS SDL.Rect

Description

Used in SDL to define a rectangular area. It is sometimes also used to specify only points or sizes (i.e only one of the position and dimension is used).


int x
int y

Description

Position of the upper-left corner of the rectangle.


int w
int h

Description

The width and height of the rectangle.

  CLASS SDL.Keysym

Description

The Keysym class is used to report key presses and releases. It's available from the SDL.Event class for keyboard events.

The scancode field should generally be left alone - it is the hardware dependent scancode returned by the keyboard. The sym field is extremely useful. It is the SDL-defined value of the key. This field is very useful when you are checking for certain key presses.

mod stores the current state of the keyboard modifiers as explained in SDL.get_mod_state() . The unicode field is only used when UNICODE translation is enabled with SDL.enable_unicode() . If unicode is non-zero then this a the UNICODE character corresponding to the keypress. If the high 9 bits of the character are 0, then this maps to the equivalent ASCII character.

Note

UNICODE translation does have a slight overhead so don't enable it unless its needed.


Variable scancode

int scancode

Description

Hardware specific scancode


Variable sym

int sym

Description

SDL virtual keysym


Variable mod

int mod

Description

Current key modifiers


Variable unicode

int unicode

Description

Translated character

  CLASS SDL.PixelFormat

Description

This describes the format of the pixel data stored at the pixels field of a SDL.Surface . Every surface stores a PixelFormat in the format field.


Variable bits_per_pixel

int bits_per_pixel

Description

The number of bits used to represent each pixel in a surface. Usually 8, 16, 24 or 32.


Variable bytes_per_pixel

int bytes_per_pixel

Description

The number of bytes used to represent each pixel in a surface. Usually one to four.


int rmask
int gmask
int bmask
int amask

Description

Binary mask used to retrieve individual color values.


int rloss
int gloss
int bloss
int aloss

Description

Precision loss of each color component.


int rshift
int gshift
int bshift
int ashift

Description

Binary left shift of each color component in the pixel value.


Variable colorkey

int colorkey

Description

Pixel value of transparent pixels.


Variable alpha

int alpha

Description

Overall surface alpha value.


Method losses

array(int) losses()

Description

Convenience method returning the RGBA precision loss as an array.


Method masks

array(int) masks()

Description

Convenience method returning the RGBA masks as an array.


Method shifts

array(int) shifts()

Description

Convenience method returning the RGBA shifts as an array.


Method map_rgb

int map_rgb(int r, int g, int b)
int map_rgb(Image.Color.Color color)

Description

Maps the RGB color value to the specified pixel format and returns the pixel value as an integer.

If the format has a palette (8-bit) the index of the closest matching color in the palette will be returned.

If the pixel format has an alpha component it will be returned as all 1 bits (fully opaque).

Parameter r
Parameter g
Parameter b

The red, green and blue components specified as an integer between 0 and 255.

Parameter color

The color as represented by an Image.Color.Color object.

Returns

A pixel value best approximating the given RGB color value for a given pixel format.

See also

map_rgba() , get_rgb() , get_rgba()


Method map_rgba

int map_rgba(int r, int g, int b, int a)
int map_rgba(Image.Color.Color color, int a)

Description

Maps the RGBA color value to the specified pixel format and returns the pixel value as an integer.

If the format has a palette (8-bit) the index of the closest matching color in the palette will be returned.

If the pixel format has an alpha component it will be returned as all 1 bits (fully opaque).

Parameter r
Parameter g
Parameter b
Parameter a

The red, green and blue components specified as an integer between 0 and 255.

Parameter color

The color as represented by an Image.Color.Color object.

Returns

A pixel value best approximating the given RGB color value for a given pixel format.

See also

map_rgb() , get_rgb() , get_rgba()


Method get_rgb

Image.Color.Color get_rgb(int pixel)

Description

Get RGB component values from a pixel stored in this pixel format.

Parameter pixel

A pixel retrieved from a surface with this pixel format or a color previously mapped with map_rgb() or map_rgba() .

Returns

A Image.Color.Color object with the RGB components of the pixel.

See also

map_rgb() , map_rgba() , get_rgba()


Method get_rgba

mapping(string:Image.Color.Color|int) get_rgba(int pixel)

Description

Get RGB component values from a pixel stored in this pixel format.

Parameter pixel

A pixel retrieved from a surface with this pixel format or a color previously mapped with map_rgb() or map_rgba() .

Returns

A mapping containing with the RGBA components of the pixel as described below.

color : Image.Color.Color

The RGB color value of the pixel.

alpha : int

The alpha value of the pixel in the range 0-255.


See also

map_rgb() , map_rgba() , get_rgb()

  CLASS SDL.VideoInfo

Description

This (read-only) class is returned by SDL.get_video_info() . It contains information on either the 'best' available mode (if called before SDL.set_video_mode() ) or the current video mode.


Variable blit_hw_cc

int blit_hw_cc

Description

Are hardware to hardware colorkey blits accelerated?


Variable blit_hw_a

int blit_hw_a

Description

Are hardware to hardware alpha blits accelerated?


Variable blit_sw

int blit_sw

Description

Are software to hardware blits accelerated?


Variable blit_sw_cc

int blit_sw_cc

Description

Are software to hardware colorkey blits accelerated?


Variable blit_sw_a

int blit_sw_a

Description

Are software to hardware alpha blits accelerated?


Variable blit_fill

int blit_fill

Description

Are color fills accelerated?


Variable video_mem

int video_mem

Description

Total amount of video memory in KB.


Variable format

SDL.PixelFormat format

Description

Pixel format of the video device.

  CLASS SDL.Surface

Description

Surface's represent areas of "graphical" memory, memory that can be drawn to. The video framebuffer is returned as a SDL.Surface by SDL.set_video_mode() and SDL.get_video_surface() .


int w
int h

Description

The width and height of the surface in pixels.


Variable clip_rect

SDL.Rect clip_rect

Description

This is the clipping rectangle as set by set_clip_rect() .


Variable flags

int flags

Description

The following are supported in the flags field.

SDL.SWSURFACE

Surface is stored in system memory

SDL.HWSURFACE

Surface is stored in video memory

SDL.ASYNCBLIT

Surface uses asynchronous blits if possible.

SDL.ANYFORMAT

Allows any pixel-format (Display surface).

SDL.HWPALETTE

Surface has exclusive palette.

SDL.DOUBLEBUF

Surface is double buffered (Display surface).

SDL.FULLSCREEN

Surface is full screen (Display Sur face).

SDL.OPENGL

Surface has an OpenGL context (Display Surface).

SDL.OPENGLBLIT

Surface supports OpenGL blitting (Display Surface).

SDL.RESIZABLE

Surface is resizable (Display Surface).

SDL.HWACCEL

Surface blit uses hardware acceleration.

SDL.SRCCOLORKEY

Surface use colorkey blitting.

SDL.RLEACCEL

Colorkey blitting is accelerated with RLE.

SDL.SRCALPHA

Surface blit uses alpha blending.

SDL.PREALLOC

Surface uses preallocated memory.


Variable format

SDL.PixelFormat format

Description

The pixel format of this surface.


Method get_pixel

int get_pixel(int x, int y)

Description

Get the value of the specified pixel. The surface needs to be locked before this method can be used.

Parameter x
Parameter y

Pixel coordinate to get.

Returns

The value of the specified pixel.

See also

set_pixel() , unlock() , lock()


Method set_pixel

int set_pixel(int x, int y, int pixel)

Description

Set the value of the specified pixel. The surface needs to be locked before this method can be used.

Parameter x
Parameter y

Pixel coordinate to modify.

Parameter pixel

Pixel value to set to the specified pixel.

Returns

A reference to the surface itself.

See also

get_pixel() , unlock() , lock()


Method lock

int lock()

Description

This methods locks the surface to allow direct access to the pixels using the get_pixel() and set_pixel() methods. Note that although all surfaces in SDL don't require locking, you still need to call this method to enable the set/get pixel methods. You should unlock the surface when you're doing modifying it.

Note

Calling this method multiple times means that you need to call unlock an equal number of times for the surface to become unlocked.

Returns

1 for success or 0 if the surface couldn't be locked.

See also

unlock() , set_pixel() , get_pixel()


Method unlock

void unlock()

Description

Surfaces that were previously locked using lock() must be unlocked with unlock() . Surfaces should be unlocked as soon as possible.

See also

lock()


Method init

SDL.Surface init(int flags, int width, int height, int depth, int Rmask, int Gmask, int Bmask, int Amask)

Description

This (re)initializes this surface using the specified parameters. Any previously allocated data will be freed. If depth is 8 bits an empty palette is allocated for the surface, otherwise a 'packed-pixel' SDL.PixelFormat is created using the [RGBA]mask's provided. width and height specifies the desired size of the image. The flags specifies the type of surface that should be created. It is an OR'd combination of the following possible values:

SDL.SWSURFACE

SDL will create the surface in system memory. This improves the performance of pixel level access, however you may not be able to take advantage of some types of hardware blitting.

SDL.HWSURFACE

SDL will attempt to create the surface in video memory. This will allow SDL to take advantage of Video->Video blits (which are often accelerated).

SDL.SRCCOLORKEY

This flag turns on colourkeying for blits from this surface. If SDL.HWSURFACE is also specified and colourkeyed blits are hardware-accelerated, then SDL will attempt to place the surface in video memory. Use set_color_key() to set or clear this flag after surface creation.

SDL.SRCALPHA

This flag turns on alpha-blending for blits from this surface. If SDL.HWSURFACE is also specified and alpha blending blits are hardware-accelerated, then the surface will be placed in video memory if possible. Use set_alpha() to set or clear this flag after surface creation.

Note

If an alpha-channel is specified (that is, if Amask is nonzero), then the SDL.SRCALPHA flag is automatically set. You may remove this flag by calling set_alpha() after surface creation.

Returns

A reference to itself.

Note

If this method fails, the surface will become uninitialized.

See also

set_image()


Method set_image

SDL.Surface set_image(Image.Image image, int|void flags)
SDL.Surface set_image(Image.Image image, Image.Image alpha, int|void flags)

Description

This (re)initializes this surface from the Image.Image in image. Any previously allocated data will be freed. If initialization is successful, this surface will use RGBA8888 format. For good blitting performance, it should be converted to the display format using display_format() .

Parameter image

The source image.

Parameter alpha

Optional alpha channel. In Pike, the alpha channel can have different alpha values for red, green and blue. Since SDL doesn't support this, only the alpha value of the red color is used in the conversion. When this calling convention is used, the surface alpha value of image is ignored.

Parameter flags

When present this specifies the type of surface that should be created. It is an OR'd combination of the following possible values:

SDL.SWSURFACE

SDL will create the surface in system memory. This improves the performance of pixel level access, however you may not be able to take advantage of some types of hardware blitting.

SDL.HWSURFACE

SDL will attempt to create the surface in video memory. This will allow SDL to take advantage of Video->Video blits (which are often accelerated).

SDL.SRCCOLORKEY

This flag turns on colourkeying for blits from this surface. If SDL.HWSURFACE is also specified and colourkeyed blits are hardware-accelerated, then SDL will attempt to place the surface in video memory. Use set_color_key() to set or clear this flag after surface creation.

SDL.SRCALPHA

This flag turns on alpha-blending for blits from this surface. If SDL.HWSURFACE is also specified and alpha blending blits are hardware-accelerated, then the surface will be placed in video memory if possible. Note that if this surface has an alpha value specified, this flag is enabled automatically. Use set_alpha() to modify this flag at a later point.

Note

If this method fails, the surface will become uninitialized.

Returns

A reference to itself.

See also

init()


Method display_format

SDL.Surface display_format()

Description

This function takes a surface and copies it to a new surface of the pixel format and colors of the video framebuffer, suitable for fast blitting onto the display surface. It calls convert_surface() .

If you want to take advantage of hardware colorkey or alpha blit acceleration, you should set the colorkey and / or alpha value before calling this function.

If you want an alpha channel, see display_format_alpha() .

Returns

The new surface. An error is thrown if the conversion fails.


Method display_format_alpha

SDL.Surface display_format_alpha()

Description

This function takes a surface and copies it to a new surface of the pixel format and colors of the video framebuffer, suitable for fast blitting onto the display surface. It calls convert_surface() .

If you want to take advantage of hardware colorkey or alpha blit acceleration, you should set the colorkey and / or alpha value before calling this function.

This function can be used to convert a colourkey to an alpha channel, if the SDL.SRCCOLORKEY flag is set on the surface. The generated surface will then be transparent (alpha=0) where the pixels match the colourkey, and opaque (alpha=255) elsewhere.

Returns

The new surface. An error is thrown if the conversion fails.

  Module Shuffler


constant Shuffler.INITIAL
constant Shuffler.RUNNING
constant Shuffler.PAUSED
constant Shuffler.DONE
constant Shuffler.WRITE_ERROR
constant Shuffler.READ_ERROR
constant Shuffler.USER_ABORT

  CLASS Shuffler.Throttler

Note

This is an interface that all Throttler s must implement. It's not an actual class in this module.


Method request

void request(Shuffle shuffle, int amount, function(int:void) callback)

Description

This function is called when the Shuffle wants to send some data to a client.

When data can be sent, the callback function should be called with the amount of data that can be sent as the argument.


Method give_back

void give_back(Shuffle shuffle, int amount)

Description

This function will be called by the Shuffle object to report that some data assigned to it by this throttler was unusued, and can be given to another Shuffle object instead.

  CLASS Shuffler.Shuffle

Description

This class contains the state for one ongoing data shuffling operation. To create a Shuffle instance, use the Shuffler()->shuffle method.


Variable shuffler

Shuffler shuffler

Description

The Shuffler that owns this Shuffle object


Variable throttler

Throttler throttler

Description

The Throttler that is associated with this Shuffle object, if any.


Method set_throttler

void set_throttler(Throttler t)

Description

Calling this function overrides the Shuffler global throttler.


Method sent_data

int sent_data()

Description

Returns the amount of data that has been sent so far.


Method state

int state()

Description

Returns the current state of the shuffler. This is one of the following: INITIAL , RUNNING , PAUSED , DONE , WRITE_ERROR , READ_ERROR and USER_ABORT


Method set_done_callback

void set_done_callback(function(Shuffle:void) cb)

Description

Sets the done callback. This function will be called when all sources have been processed, or if an error occurs.


Method set_request_arg

void set_request_arg(mixed arg)

Description

Sets the extra argument sent to Throttler()->request() and Throttler()->give_back .


Method start

void start()

Description

Start sending data from the sources.


Method pause

void pause()

Description

Temporarily pause all data transmission


Method stop

void stop()

Description

Stop all data transmission, and then call the done callback


Method add_source

void add_source(mixed source, int|void start, int|void length)

Description

Add a new source to the list of data sources. The data from the sources will be sent in order.

If start and length are not specified, the whole source will be sent, if start but not length is specified, the whole source, excluding the first start bytes will be sent.

Currently supported sources

String

An ordinary 8-bit wide pike string.

Memory

An initialized instance of the System.Memory class.

NormalFile

Stdio.File instance pointing to a normal file.

Stream

Stdio.File instance pointing to a stream of some kind (network socket, named pipe, stdin etc).

Pike-stream

Stdio.File lookalike with read callback support (set_read_callback and set_close_callback).

  CLASS Shuffler.Shuffler

Description

A data shuffler. An instance of this class handles a list of Shuffle objects. Each Shuffle object can send data from one or more sources to a destination in the background.


Method set_backend

void set_backend(Backend b)

Description

Set the backend that will be used by all Shuffle objects created from this shuffler.


Method set_throttler

void set_throttler(Throttler t)

Description

Set the throttler that will be used in all Shuffle objects created from this shuffler, unless overridden in the Shuffle objects.


Method pause

void pause()

Description

Pause all Shuffle objects associated with this Shuffler


Method start

void start()

Description

Unpause all Shuffle objects associated with this Shuffler


Method shuffle

Shuffle shuffle(Stdio.File destination)

Description

Create a new Shuffle object.

  Module Unicode


Method split_words

array(string) Unicode.split_words(string intput)

FIXME

Document this function.


Method split_words_and_normalize

array(string) Unicode.split_words_and_normalize(string input)

FIXME

Document this function.


Method normalize

string Unicode.normalize(string data, string method)

Description

Normalize the given unicode string according to the specified method.

The methods are:

NFC, NFD, NFKC and NFKD.

The methods are described in detail in the UAX #15 document, which can currently be found at http://www.unicode.org/unicode/reports/tr15/tr15-21.html

A short description:

C and D specifies whether to decompose (D) complex characters to their parts, or compose (C) single characters to complex ones.

K specifies whether or not do a canonical or compatibility conversion. When K is present, compatibility transformations are performed as well as the canonical transformations.

In the following text, 'X' denotes the single character 'X', even if there is more than one character inside the quotation marks. The reson is that it's somewhat hard to describe unicode in iso-8859-1.

The Unicode Standard defines two equivalences between characters: canonical equivalence and compatibility equivalence. Canonical equivalence is a basic equivalency between characters or sequences of characters.

'Å' and 'A' '° (combining ring above)' are canonically equivalent.

For round-trip compatibility with existing standards, Unicode has encoded many entities that are really variants of existing nominal characters. The visual representations of these character are typically a subset of the possible visual representations of the nominal character. These are given compatibility decompositions in the standard. Because the characters are visually distinguished, replacing a character by a compatibility equivalent may lose formatting information unless supplemented by markup or styling.

Examples of compatibility equivalences:

  • Font variants (thin, italic, extra wide characters etc)

  • Circled and squared characters

  • super/subscript ('²' -> '2')

  • Fractions ('½' -> '1/2')

  • Other composed characters ('fi' -> 'f' 'i', 'kg' -> 'k' 'g')


Method is_wordchar

int Unicode.is_wordchar(int c)

FIXME

Document this function.

  Module CommonLog

Description

The CommonLog module is used to parse the lines in a www server's logfile, which must be in "common log" format -- such as used by default for the access log by Roxen, Caudium, Apache et al.


Method read

int CommonLog.read(function(array(int|string):void) callback, Stdio.File|string logfile, void|int offset)

Description

Reads the log file and calls the callback function for every parsed line. For lines that fails to be parsed the callback is not called not is any error thrown. The number of bytes read are returned.

Parameter callback

The callbacks first argument is an array with the different parts of the log entry.

Array
string remote_host 
int(0..0)|string ident_user 
int(0..0)|string auth_user 
int year 
int month 
int day 
int hours 
int minutes 
int seconds 
int timezone 
int(0..0)|string method

One of "GET", "POST", "HEAD" etc.

int(0..0)|string path 
string protocol

E.g. "HTTP/1.0"

int reply_code

One of 200, 404 etc.

int bytes 

The second callback argument is the current offset to the end of the current line.

Parameter offset

The position in the file where the parser should begin.

  Module DVB

Description

Implements Digital Video Broadcasting interface

Note

Only Linux version is supported.

  CLASS DVB.dvb

Description

Main class.


Method create

void DVB.dvb(int card_number)

Description

Create a DVB object.

Parameter card_number

The number of card equipment.

Note

The number specifies which device will be opened. Ie. /dev/ost/demux0, /dev/ost/demux1 ... for DVB v0.9.4 or /dev/dvb/demux0, /dev/dvb/demux1 ... for versions 2.0+


Method fe_status

mapping|int fe_status()

Description

Return status of a DVB object's frondend device.

Returns

The resulting mapping contains the following fields:

"power" : string

If 1 the frontend is powered up and is ready to be used.

"signal" : string

If 1 the frontend detects a signal above a normal noise level

"lock" : string

If 1 the frontend successfully locked to a DVB signal

"carrier" : string

If 1 carrier dectected in signal

"biterbi" : string

If 1 then lock at viterbi state

"sync" : string

If 1 then TS sync byte detected

"tuner_lock" : string

If 1 then tuner has a frequency lock



Method fe_info

mapping fe_info()

Description

Return info of a frondend device.

Note

The information heavily depends on driver. Many fields contain dumb values.


Method tune

int tune(int(0..3) lnb, int freq, int(0..1)|string pol, int sr)

Description

Tunes to apropriate transponder's parameters.

Parameter lnb

DiSeQc number of LNB.

Parameter freq

Frequency divided by 1000.

Parameter pol

Polarization. 0 or "v" for vertical type, 1 or "h" for horizontal one.

Parameter sr

The service rate parameter.


Method get_pids

mapping|int get_pids()

Description

Returns mapping with info of currently tuned program's pids.

See also

tune()


Method analyze_pat

mapping analyze_pat()

Description

Return mapping of all PMT.

sid:prognum


Method analyze_pmt

array(mapping)|int analyze_pmt(int sid, int prognum)

Description

Parse PMT table.

See also

analyze_pat()


Method stream

DVB.Stream stream(int pid, int|function rcb, int ptype)
DVB.Stream stream(int pid, int|function rcb)
DVB.Stream stream(int pid)

Description

Create a new stream reader object for PID.

Parameter pid

PID of stream.

Parameter rcb

Callback function called whenever there is the data to read from stream. Only for nonblocking mode.

Parameter ptype

Type of payload data to read. By default, audio data is fetched.

Note

Setting async callback doesn't set the object to nonblocking state.

See also

DVB.Stream()->read()

  CLASS DVB.Stream

Description

Represents an elementary data stream (PES).


Method destroy

int destroy()

Description

Purge a stream reader.

See also

DVB.dvb()->stream() , read()


Method read

string|int read()

Description

Read data from a stream. It reads up to read buffer size data.

Note

Read buffer size is 4096 by default.

See also

DVB.dvb()->stream() , close()


Method close

void close()

Description

Closes an open stream.

See also

read()

  CLASS DVB.Audio

Description

Object for controlling an audio subsystem on full featured cards.


Method create

void DVB.Audio(int card_number)
void DVB.Audio()

Description

Create a Audio object.

Parameter card_number

The number of card equipment.


Method mute

int mute(int mute)
int mute()

Description

Mute or unmute audio device.


Method status

mapping status()

Description

Returns mapping of current audio device status.


Method mixer

int mixer(int left, int right)
int mixer(int both)

Description

Sets output level on DVB audio device.

  Module Locale

Description

The functions and classes in the top level of the Locale module implements a dynamic localization system, suitable for programs that needs to change locale often. It is even possible for different threads to use different locales at the same time.

The highest level of the locale system is called projects. Usually one program consists of only one project, but for bigger applications, or highly modular applications it is possible for several projects to coexist.

Every project in turn contains several unique tokens, each one representing an entity that is different depending on the currently selected locale.

Example

// The following line tells the locale extractor what to // look for. // <locale-token project="my_project">LOCALE</locale-token>

// The localization macro. #define LOCALE(X,Y) Locale.translate("my_project", \ get_lang(), X, Y)

string get_lang() { return random(2)?"eng":"swe"; }

int(0..0) main() { write(LOCALE(0, "This is a line.")+"\n"); write(LOCALE(0, "This is another one.\n"); return 0; }


Method register_project

void Locale.register_project(string name, string path, void|string path_base)

Description

Make a connection between a project name and where its localization files can be found. The mapping from project name to locale file is stored in projects.


Method set_default_project_path

void Locale.set_default_project_path(string path)

Description

In the event that a translation is requested in an unregistered project, this path will be used as the project path. %P will be replaced with the requested projects name.


Method list_languages

array(string) Locale.list_languages(string project)

Description

Returns a list of all registered languages for a specific project.


Method get_objects

mapping(string:object) Locale.get_objects(string lang)

Description

Reads in and returns a mapping with all the registred projects' LocaleObjects in the language 'lang'


Method translate

string Locale.translate(string project, string lang, string|int id, string fallback)

Description

Returns a translation for the given id, or the fallback string


Method call

function Locale.call(string project, string lang, string name, void|function|string fb)

Description

Returns a localized function If function not found, tries fallback function fb, or fallback language fb instead

  CLASS Locale.DeferredLocale

Description

This class simulates a multi-language "string". The actual language to use is determined as late as possible.


Method get_identifier

array get_identifier()

Description

Return the data nessesary to recreate this "string".

  Module Locale.Gettext

Description

This module enables access to localization functions from within Pike.


Method gettext

string Locale.Gettext.gettext(string msg)
string Locale.Gettext.gettext(string msg, string domain)
string Locale.Gettext.gettext(string msg, string domain, int category)

Parameter msg

Message to be translated.

Parameter domain

Domain from within the message should be translated. Defaults to the current domain.

Parameter category

Category from which the translation should be taken. Defaults to Locale.Gettext.LC_MESSAGES .

Return a translated version of msg within the context of the specified domain and current locale. If there is no translation available, msg is returned.

Note

Prior to Pike 7.3 this function only accepted one argument, and the other functionality was provided by dgettext() and dcgettext() .

See also

bindtextdomain , textdomain , setlocale , localeconv


Method dgettext

string Locale.Gettext.dgettext(string domain, string msg)

Description

Return a translated version of msg within the context of the specified domain and current locale. If there is no translation available, msg is returned.

Note

Obsoleted by gettext() in Pike 7.3.

See also

bindtextdomain , textdomain , gettext , setlocale , localeconv


Method dcgettext

string Locale.Gettext.dcgettext(string domain, string msg, int category)

Description

Return a translated version of msg within the context of the specified domain and current locale for the specified category . Calling dcgettext with category Locale.Gettext.LC_MESSAGES gives the same result as dgettext.

If there is no translation available, msg is returned.

Note

Obsoleted by gettext() in Pike 7.3.

See also

bindtextdomain , textdomain , gettext , setlocale , localeconv


Method textdomain

string Locale.Gettext.textdomain(void|string domain)

Description

The textdomain() function sets or queries the name of the current domain of the active LC_MESSAGES locale category. The domain argument is a string that can contain only the characters allowed in legal filenames.

The domain argument is the unique name of a domain on the system. If there are multiple versions of the same domain on one system, namespace collisions can be avoided by using bindtextdomain() . If textdomain() is not called, a default domain is selected. The setting of domain made by the last valid call to textdomain() remains valid across subsequent calls to setlocale() , and gettext() .

Returns

The normal return value from textdomain() is a string containing the current setting of the domain. If domainname is void, textdomain() returns a string containing the current domain. If textdomain() was not previously called and domainname is void, the name of the default domain is returned.

See also

bindtextdomain , gettext , setlocale , localeconv


Method bindtextdomain

string Locale.Gettext.bindtextdomain(string|void domainname, string|void dirname)

Description

Binds the path predicate for a message domainname domainname to the directory name specified by dirname . If domainname is a non-empty string and has not been bound previously, bindtextdomain() binds domainname with dirname .

If domainname is a non-empty string and has been bound previously, bindtextdomain() replaces the old binding with dirname . The dirname argument can be an absolute or relative pathname being resolved when gettext() , dgettext() or dcgettext() are called. If domainname is zero or an empty string, bindtextdomain() returns 0.

User defined domain names cannot begin with the string "SYS_". Domain names beginning with this string are reserved for system use.

Returns

The return value from bindtextdomain() is a string containing dirname or the directory binding associated with domainname if dirname is unspecified. If no binding is found, the default locale path is returned. If domainname is unspecified or is an empty string, bindtextdomain() takes no action and returns a 0.

See also

textdomain , gettext , setlocale , localeconv


Method setlocale

int Locale.Gettext.setlocale(int category, string locale)

Description

The setlocale() function is used to set the program's current locale. If locale is "C" or "POSIX", the current locale is set to the portable locale.

If locale is "", the locale is set to the default locale which is selected from the environment variable LANG.

The argument category determines which functions are influenced by the new locale are LC_ALL , LC_COLLATE , LC_CTYPE , LC_MONETARY , LC_NUMERIC and LC_TIME .

Returns

Returns 1 if the locale setting successed, 0 for failure

See also

bindtextdomain , textdomain , gettext , dgettext , dcgettext , localeconv


Method localeconv

mapping Locale.Gettext.localeconv()

Description

The localeconv() function returns a mapping with settings for the current locale. This mapping contains all values associated with the locale categories LC_NUMERIC and LC_MONETARY .

"decimal_point" : string

The decimal-point character used to format non-monetary quantities.

"thousands_sep" : string

The character used to separate groups of digits to the left of the decimal-point character in formatted non-monetary quantities.

"int_curr_symbol" : string

The international currency symbol applicable to the current locale, left-justified within a four-character space-padded field. The character sequences should match with those specified in ISO 4217 Codes for the Representation of Currency and Funds.

"currency_symbol" : string

The local currency symbol applicable to the current locale.

"mon_decimal_point" : string

The decimal point used to format monetary quantities.

"mon_thousands_sep" : string

The separator for groups of digits to the left of the decimal point in formatted monetary quantities.

"positive_sign" : string

The string used to indicate a non-negative-valued formatted monetary quantity.

"negative_sign" : string

The string used to indicate a negative-valued formatted monetary quantity.

"int_frac_digits" : int

The number of fractional digits (those to the right of the decimal point) to be displayed in an internationally formatted monetary quantity.

"frac_digits" : int

The number of fractional digits (those to the right of the decimal point) to be displayed in a formatted monetary quantity.

"p_cs_precedes" : int(0..1)

Set to 1 or 0 if the currency_symbol respectively precedes or succeeds the value for a non-negative formatted monetary quantity.

"p_sep_by_space" : int(0..1)

Set to 1 or 0 if the currency_symbol respectively is or is not separated by a space from the value for a non-negative formatted monetary quantity.

"n_cs_precedes" : int(0..1)

Set to 1 or 0 if the currency_symbol respectively precedes or succeeds the value for a negative formatted monetary quantity.

"n_sep_by_space" : int(0..1)

Set to 1 or 0 if the currency_symbol respectively is or is not separated by a space from the value for a negative formatted monetary quantity.

"p_sign_posn" : int(0..4)

Set to a value indicating the positioning of the positive_sign for a non-negative formatted monetary quantity. The value of p_sign_posn is interpreted according to the following:

0

Parentheses surround the quantity and currency_symbol.

1

The sign string precedes the quantity and currency_symbol.

2

The sign string succeeds the quantity and currency_symbol.

3

The sign string immediately precedes the currency_symbol.

4

The sign string immediately succeeds the currency_symbol.


"n_sign_posn" : int

Set to a value indicating the positioning of the negative_sign for a negative formatted monetary quantity. The value of n_sign_posn is interpreted according to the rules described under p_sign_posn.


See also

bindtextdomain , textdomain , gettext , dgettext , dcgettext , setlocale


Constant LC_ALL

constant Locale.Gettext.LC_ALL

Description

Locale category for all of the locale.


Constant LC_COLLATE

constant Locale.Gettext.LC_COLLATE

Description

Locale category for the functions strcoll() and strxfrm() (used by pike, but not directly accessible).


Constant LC_CTYPE

constant Locale.Gettext.LC_CTYPE

Description

Locale category for the character classification and conversion routines.


Constant LC_MESSAGES

constant Locale.Gettext.LC_MESSAGES

FIXME

Document this constant.

Note

This category isn't available on all platforms.


Constant LC_MONETARY

constant Locale.Gettext.LC_MONETARY

Description

Locale category for localeconv().


Constant LC_NUMERIC

constant Locale.Gettext.LC_NUMERIC

Description

Locale category for the decimal character.


Constant LC_TIME

constant Locale.Gettext.LC_TIME

Description

Locale category for strftime() (currently not accessible from Pike).

  Module Locale.Language

  CLASS Locale.Language.abstract

Description

Abstract language locale class, inherited by all the language locale classes.


Constant months

constant months

Description

Array(string) with the months of the year, beginning with January.


Constant days

constant days

Description

Array(string) with the days of the week, beginning with Sunday.


Constant iso_639_1

constant iso_639_1

Description

String with the language code in ISO-639-1 (two character code). Note that all languages does not have a ISO-639-1 code.


Constant iso_639_2

constant iso_639_2

Description

String with the language code in ISO-639-2/T (three character code).


Constant iso_639_2B

constant iso_639_2B

Description

String with the language code in ISO-639-2/B (three character code). This is usually the same as the ISO-639-2/T code (iso_639_2 ).


Constant english_name

constant english_name

Description

The name of the language in english.


Constant name

constant name

Description

The name of the langauge. E.g. "svenska" for Swedish.


Constant languages

constant languages

Description

Mapping(string:string) that maps an ISO-639-2/T id code to the name of that language.


Method month

string month(int(1..12) num)

Description

Returns the name of month number num .


Method day

string day(int(1..7) num)

Description

Returns the name of weekday number num .


Method number

string number(int i)

Description

Returns the number i as a string.


Method ordered

string ordered(int i)

Description

Returns the ordered number i as a string.


Method date

string date(int timestamp, string|void mode)

Description

Returns the date for posix time timestamp as a textual string.

Parameter mode

Determines what kind of textual string should be produced.

"time"

I.e. "06:36"

"date"

I.e. "January the 17th in the year of 2002"

"full"

I.e. "06:37, January the 17th, 2002"


Example

> Locale.Language.eng()->date(time()); Result: "today, 06:36"

  Module Locale.Language.cat

Description

Catalan language locale.


Inherit "abstract"

inherit "abstract"

  Module Locale.Language.ces

Description

Czech language locale by Jan Petrous 16.10.1997, based on Slovenian language module by Iztok Umek.


Inherit "abstract"

inherit "abstract"

  Module Locale.Language.deu

Description

German language locale by Tvns Böker.


Inherit "abstract"

inherit "abstract"

  Module Locale.Language.eng

Description

English language locale.


Inherit "abstract"

inherit "abstract"

  Module Locale.Language.fin

Description

Finnish language locale created by Janne Edelman, Turku Unix Users Group ry, Turku, Finland


Inherit "abstract"

inherit "abstract"

  Module Locale.Language.fra

Description

French language locale by Patrick Kremer.


Inherit "abstract"

inherit "abstract"

  Module Locale.Language.hrv

Description

Croatian language locale by Klara Makovac 1997/07/02


Inherit "abstract"

inherit "abstract"

  Module Locale.Language.hun

Description

Hungarian language locale by Zsolt Varga.


Inherit "abstract"

inherit "abstract"

  Module Locale.Language.ita

Description

Italian language locale by Francesco Chemolli


Inherit "abstract"

inherit "abstract"

  Module Locale.Language.jpn

Description

Japanese language locale.


Inherit "abstract"

inherit "abstract"

  Module Locale.Language.mri

Description

Maaori (New Zealand) language locale by Jason Rumney


Inherit "abstract"

inherit "abstract"

  Module Locale.Language.nld

Description

Dutch language locale by Stephen R. van den Berg


Inherit "abstract"

inherit "abstract"

  Module Locale.Language.nor

Description

Norwegian language locale


Inherit "abstract"

inherit "abstract"

  Module Locale.Language.pol

Description

Polish language locale by Piotr Klaban.


Inherit "abstract"

inherit "abstract"

  Module Locale.Language.por

Description

Portuguese language locale


Inherit "abstract"

inherit "abstract"

  Module Locale.Language.rus

Description

Russian language locale


Inherit "abstract"

inherit "abstract"

  Module Locale.Language.slv

Description

Slovenian language locale by Iztok Umek 7. 8. 1997


Inherit "abstract"

inherit "abstract"

  Module Locale.Language.spa

Description

Spanish language locale


Inherit "abstract"

inherit "abstract"

  Module Locale.Language.srp

Description

Serbian language locale by Goran Opacic 1996/12/11


Inherit "abstract"

inherit "abstract"

  Module Locale.Language.swe

Description

Swedish language locale


Inherit "abstract"

inherit "abstract"

  Module Locale.Charset

Description

The Charset module supports a wide variety of different character sets, and it is flexible in regard of the names of character sets it accepts. The character case is ignored, as are the most common non-alaphanumeric characters appearing in character set names. E.g. "iso-8859-1" works just as well as "ISO_8859_1". All encodings specified in RFC 1345 are supported4

First of all the Charset module is capable of handling the following encodings of Unicode:

  • utf7, utf8, utf16, utf16be, utf16le, utf75 and utf7½

    UTF encodings

  • shifjis, euc-kr, euc-cn and euc-jp

Most, if not all, of the relevant code pages are represented, as the following list shows. Prefix the numbers as noted in the list to get the wanted codec:

  • 037, 038, 273, 274, 275, 277, 278, 280, 281, 284, 285, 290, 297, 367, 420, 423, 424, 437, 500, 819, 850, 851, 852, 855, 857, 860, 861, 862, 863, 864, 865, 866, 868, 869, 870, 871, 880, 891, 903, 904, 905, 918, 950 and 1026

    These may be prefixed with "cp" or "ibm".

  • 1250, 1251, 1252, 1253, 1254, 1255, 1256, 1257 and 1258

    These may be prefixed with "cp", "ibm" or "windows".

+359 more.


Method decoder

ascii Locale.Charset.decoder(string name)

Description

Returns a charset decoder object.

Parameter name

The name of the character set to decode from. Supported charsets include (not all supported charsets are enumerable): "iso_8859-1:1987", "iso_8859-1:1998", "iso-8859-1", "iso-ir-100", "latin1", "l1", "ansi_x3.4-1968", "iso_646.irv:1991", "iso646-us", "iso-ir-6", "us", "us-ascii", "ascii", "cp367", "ibm367", "cp819", "ibm819", "iso-2022" (of various kinds), "utf-7", "utf-8" and various encodings as described by RFC1345.

Throws

If the asked-for name was not supported, an error is thrown.


Method encoder

_encoder Locale.Charset.encoder(string name, string|void replacement, function(string:string)|void repcb)

Description

Returns a charset encoder object.

Parameter name

The name of the character set to decode from. Supported charsets include (not all supported charsets are enumerable): "iso_8859-1:1987", "iso_8859-1:1998", "iso-8859-1", "iso-ir-100", "latin1", "l1", "ansi_x3.4-1968", "iso_646.irv:1991", "iso646-us", "iso-ir-6", "us", "us-ascii", "ascii", "cp367", "ibm367", "cp819", "ibm819", "iso-2022" (of various kinds), "utf-7", "utf-8" and various encodings as described by RFC1345.

Throws

If the asked-for name was not supported, an error is thrown.

  Module Gmp

  CLASS Gmp.mpz


Method create

void Gmp.mpz()
void Gmp.mpz(string|int|float|object value)
void Gmp.mpz(string value, int(2..36)|int(256..256) base)

Description

Create and initialize a Gmp.mpz object.

Parameter value

Initial value. If no value is specified, the object will be initialized to zero.

Parameter base

Base the value is specified in. The default base is base 10. The base can be either a value in the range [2..36] (inclusive), in which case the numbers are taken from the ASCII range 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ (case-insensitive), or the value 256, in which case value is taken to be the binary representation in network byte order.

Note

Leading zeroes in value are not significant. In particular leading NUL characters are not preserved in base 256 mode.

  CLASS Gmp.mpf


Method create

void Gmp.mpf(void|int|string|float|object x, void|int(0..) precision)
void Gmp.mpf(string x, int(0..) precision, int(2..36) base)


Method __hash

int __hash()


Method get_int

int|object get_int()


Method get_float

float get_float()

Description

Returns the value of the object as a float.


Method get_string

string get_string()


Method _sprintf

string _sprintf(int c, mapping flags)


Method _is_type

int(0..1) _is_type(string arg)

Description

The Gmp.mpf object will claim to be a "float".

FIXME

Perhaps it should also return true for "object"?


Method cast

mixed cast(string to)


Method `+

Gmp.mpf `+(int|float|object ... a)


Method `+=

Gmp.mpf `+=(int|float|object ... a)


Method set_precision

Gmp.mpf set_precision(int(0..) prec)

Description

Sets the precision of the current object to be at least prec bits. The precision is limited to 128Kb. The current object will be returned.

  Module Gz

Description

The Gz module contains functions to compress and uncompress strings using the same algorithm as the program gzip. Compressing can be done in streaming mode or all at once.

The Gz module consists of two classes; Gz.deflate and Gz.inflate. Gz.deflate is used to pack data and Gz.inflate is used to unpack data. (Think "inflatable boat")

Note

Note that this module is only available if the gzip library was available when Pike was compiled.

Note that although these functions use the same algorithm as gzip, they do not use the exact same format, so you cannot directly unzip gzipped files with these routines. Support for this will be added in the future.


Inherit "___predef::"

inherit "___predef::"


Method crc32

int Gz.crc32(string data, void|int start_value)

Description

This function calculates the standard ISO3309 Cyclic Redundancy Check.

  CLASS Gz.File

Description

Allows the user to open a Gzip archive and read and write it's contents in an uncompressed form, emulating the Stdio.File interface.

Note

An important limitation on this class is that it may only be used for reading or writing, not both at the same time. Please also note that if you want to reopen a file for reading after a write, you must close the file before calling open or strange effects might be the result.


Inherit _file

inherit _file : _file


Method create

void Gz.File(void|string|int file, void|string mode)

Parameter file

Filename or filedescriptor of the gzip file to open.

Parameter mode

mode for the file. Defaults to "rb".

See also

open Stdio.File


Method open

int open(string|int file, void|string mode)

Parameter file

Filename or filedescriptor of the gzip file to open.

Parameter mode

mode for the file. Defaults to "rb". May be one of the following:

rb

read mode

wb

write mode

ab

append mode

For the wb and ab mode, additional parameters may be specified. Please se zlib manual for more info.

Returns

non-zero if successful.


Method read

int|string read(void|int length)

Description

Reads data from the file. If no argument is given, the whole file is read.

  CLASS Gz.deflate

Description

Gz_deflate is a builtin program written in C. It interfaces the packing routines in the libz library.

Note

This program is only available if libz was available and found when Pike was compiled.

See also

Gz.inflate()


Method create

void Gz.deflate(int(0..9)|void X)

Description

If given, X should be a number from 0 to 9 indicating the packing / CPU ratio. Zero means no packing, 2-3 is considered 'fast', 6 is default and higher is considered 'slow' but gives better packing.

This function can also be used to re-initialize a Gz.deflate object so it can be re-used.


Method deflate

string deflate(string data, int|void flush)

Description

This function performs gzip style compression on a string data and returns the packed data. Streaming can be done by calling this function several times and concatenating the returned data.

The optional argument flush should be one of the following:

Gz.NO_FLUSH

Only data that doesn't fit in the internal buffers is returned.

Gz.PARTIAL_FLUSH

All input is packed and returned.

Gz.SYNC_FLUSH

All input is packed and returned.

Gz.FINISH

All input is packed and an 'end of data' marker is appended.


See also

Gz.inflate->inflate()

  CLASS Gz.inflate

Description

Gz_deflate is a builtin program written in C. It interfaces the unpacking routines in the libz library.

Note

This program is only available if libz was available and found when Pike was compiled.

See also

deflate


Method create

void Gz.inflate()


Method inflate

string inflate(string data)

Description

This function performs gzip style decompression. It can inflate a whole file at once or in blocks.

Example

// whole file write(Gz_inflate()->inflate(stdin->read(0x7fffffff));

// streaming (blocks) function inflate=Gz_inflate()->inflate; while(string s=stdin->read(8192)) write(inflate(s));

See also

Gz.deflate->deflate()

  CLASS Gz._file

Description

Low-level implementation of read/write support for GZip files


Method open

int open(string|int file, void|string mode)

Description

Opens a file for I/O.

Parameter file

The filename or an open filedescriptor for the GZip file to use.

Parameter mode

Mode for the fileoperations. Defaults to read only.

Note

If the object already has been opened, it will first be closed.


Method create

void Gz._file(void|string gzFile, void|string mode)

Description

Opens a gzip file for reading.


Method close

int close()

Description

closes the file

Returns

1 if successful


Method read

int|string read(int len)

Description

Reads len (uncompressed) bytes from the file. If read is unsuccessful, 0 is returned.


Method write

int write(string data)

Description

Writes the data to the file.

Returns

the number of bytes written to the file.


Method seek

int seek(int pos, void|int type)

Description

Seeks within the file.

Parameter pos

Position relative to the searchtype.

Parameter type

SEEK_SET = set current position in file to pos SEEK_CUR = new position is current+pos SEEK_END is not supported.

Returns

New position or negative number if seek failed.

Note

Not supported on all operating systems.


Method tell

int tell()

Returns

the current position within the file.

Note

Not supported on all operating systems.


Method eof

int(0..1) eof()

Returns

1 if EOF has been reached.

Note

Not supported on all operating systems.


Method setparams

int setparams(int level, int strategy)

Description

Sets the encoding level and strategy

Parameter level

Level of the compression. 0 is the least compression, 9 is max. 8 is default.

Parameter strategy

Set strategy for encoding to one of the following: Z_DEFAULT_STRATEGY Z_FILTERED Z_HUFFMAN_ONLY

Note

Not supported on all operating systems.

  Module MIME

Description

RFC1521, the Multipurpose Internet Mail Extensions memo, defines a structure which is the base for all messages read and written by modern mail and news programs. It is also partly the base for the HTTP protocol. Just like RFC822, MIME declares that a message should consist of two entities, the headers and the body. In addition, the following properties are given to these two entities:

Headers
  • A MIME-Version header must be present to signal MIME compatibility

  • A Content-Type header should be present to describe the nature of the data in the message body. Seven major types are defined, and an extensive number of subtypes are available. The header can also contain attributes specific to the type and subtype.

  • A Content-Transfer-Encoding may be present to notify that the data of the body is encoded in some particular encoding.

Body
  • Raw data to be interpreted according to the Content-Type header

  • Can be encoded using one of several Content-Transfer-Encodings to allow transport over non 8bit clean channels

The MIME module can extract and analyze these two entities from a stream of bytes. It can also recreate such a stream from these entities. To encapsulate the headers and body entities, the class MIME.Message is used. An object of this class holds all the headers as a mapping from string to string, and it is possible to obtain the body data in either raw or encoded form as a string. Common attributes such as message type and text char set are also extracted into separate variables for easy access.

The Message class does not make any interpretation of the body data, unless the content type is multipart. A multipart message contains several individual messages separated by boundary strings. The create method of the Message class will divide a multipart body on these boundaries, and then create individual Message objects for each part. These objects will be collected in the array body_parts within the original Message object. If any of the new Message objects have a body of type multipart, the process is of course repeated recursively.


Method decode_base64

string MIME.decode_base64(string encoded_data)

Description

This function decodes data encoded using the base64 transfer encoding.

See also

MIME.encode_base64() , MIME.decode()


Method encode_base64

string MIME.encode_base64(string data, void|int no_linebreaks)

Description

This function encodes data using the base64 transfer encoding.

If a nonzero value is passed as no_linebreaks , the result string will not contain any linebreaks.

See also

MIME.decode_base64() , MIME.encode()


Method decode_qp

string MIME.decode_qp(string encoded_data)

Description

This function decodes data encoded using the quoted-printable (a.k.a. quoted-unreadable) transfer encoding.

See also

MIME.encode_qp() , MIME.decode()


Method encode_qp

string MIME.encode_qp(string data, void|int no_linebreaks)

Description

This function encodes data using the quoted-printable (a.k.a. quoted-unreadable) transfer encoding.

If a nonzero value is passed as no_linebreaks , the result string will not contain any linebreaks.

Note

Please do not use this function. QP is evil, and there's no excuse for using it.

See also

MIME.decode_qp() , MIME.encode()


Method decode_uue

string MIME.decode_uue(string encoded_data)

Description

This function decodes data encoded using the x-uue transfer encoding. It can also be used to decode generic UUEncoded files.

See also

MIME.encode_uue() , MIME.decode()


Method encode_uue

string MIME.encode_uue(string encoded_data, void|string filename)

Description

This function encodes data using the x-uue transfer encoding.

The optional argument filename specifies an advisory filename to include in the encoded data, for extraction purposes.

This function can also be used to produce generic UUEncoded files.

See also

MIME.decode_uue() , MIME.encode()


Method tokenize

array(string|int) MIME.tokenize(string header)

Description

A structured header field, as specified by RFC822, is constructed from a sequence of lexical elements.

These are:

individual special characters

quoted-strings

domain-literals

comments

atoms

This function will analyze a string containing the header value, and produce an array containing the lexical elements.

Individual special characters will be returned as characters (i.e. ints).

Quoted-strings, domain-literals and atoms will be decoded and returned as strings.

Comments are not returned in the array at all.

Note

As domain-literals are returned as strings, there is no way to tell the domain-literal [127.0.0.1] from the quoted-string "[127.0.0.1]". Hopefully this won't cause any problems. Domain-literals are used seldom, if at all, anyway...

The set of special-characters is the one specified in RFC1521 (i.e. "<", ">", "@", ",", ";", ":", "\", "/", "?", "="), and not the set specified in RFC822.

See also

MIME.quote() , tokenize_labled() , decode_words_tokenized_remapped() .


Method tokenize_labled

array(array(string|int)) MIME.tokenize_labled(string header)

Description

Similar to tokenize() , but labels the contents, by making arrays with two elements; the first a label, and the second the value that tokenize() would have put there, except for that comments are kept.

The following labels exist:

"encoded-word"

Word encoded according to =?...

"special"

Special character.

"word"

Word.

"domain-literal"

Domain literal.

"comment"

Comment.


See also

MIME.quote() , tokenize() , decode_words_tokenized_labled_remapped()


Method quote

string MIME.quote(array(string|int) lexical_elements)

Description

This function is the inverse of the MIME.tokenize function.

A header field value is constructed from a sequence of lexical elements. Characters (ints) are taken to be special-characters, whereas strings are encoded as atoms or quoted-strings, depending on whether they contain any special characters.

Note

There is no way to construct a domain-literal using this function. Neither can it be used to produce comments.

See also

MIME.tokenize()


Method quote_labled

string MIME.quote_labled(array(array(string|int)) tokens)

Description

This function performs the reverse operation of tokenize_labled() .

See also

MIME.quote() , MIME.tokenize_labled()


Inherit ___MIME

inherit ___MIME : ___MIME


Method generate_boundary

string MIME.generate_boundary()

Description

This function will create a string that can be used as a separator string for multipart messages. The generated string is guaranteed not to appear in base64, quoted-printable, or x-uue encoded data. It is also unlikely to appear in normal text. This function is used by the cast method of the Message class if no boundary string is specified.


Method decode

string MIME.decode(string data, string encoding)

Description

Extract raw data from an encoded string suitable for transport between systems.

The encoding can be any of

"7bit"
"8bit"
"base64"
"binary"
"quoted-printable"
"x-uue"
"x-uuencode"

The encoding string is not case sensitive.

See also

MIME.encode()


Method encode

string MIME.encode(string data, string encoding, void|string filename, void|int no_linebreaks)

Description

Encode raw data into something suitable for transport to other systems.

The encoding can be any of

"7bit"
"8bit"
"base64"
"binary"
"quoted-printable"
"x-uue"
"x-uuencode"

The encoding string is not case sensitive. For the x-uue encoding, an optional filename string may be supplied.

If a nonzero value is passed as no_linebreaks , the result string will not contain any linebreaks (base64 and quoted-printable only).

See also

MIME.decode()


Method decode_word

array(string) MIME.decode_word(string word)

Description

Extracts the textual content and character set from an encoded word as specified by RFC1522. The result is an array where the first element is the raw text, and the second element the name of the character set. If the input string is not an encoded word, the result is still an array, but the char set element will be set to 0.

Note

Note that this function can only be applied to individual encoded words.

See also

MIME.encode_word()


Method encode_word

string MIME.encode_word(string|array(string) word, string encoding)

Description

Create an encoded word as specified in RFC1522 from an array containing a raw text string and a char set name.

The text will be transfer encoded according to the encoding argument, which can be either "base64" or "quoted-printable" (or either "b" or "q" for short).

If either the second element of the array (the char set name), or the encoding argument is 0, the raw text is returned as is.

See also

MIME.decode_word()


Method decode_words_text

array(array(string)) MIME.decode_words_text(string txt)

Description

Separates a header value containing text into units and calls MIME.decode_word() on them. The result is an array where each element is a result from decode_word().

See also

MIME.decode_words_tokenized MIME.decode_words_text_remapped


Method decode_words_text_remapped

string MIME.decode_words_text_remapped(string txt)

Description

Like MIME.decode_words_text() , but the extracted strings are also remapped from their specified character encoding into UNICODE, and then pasted together. The result is thus a string in the original text format, without RFC1522 escapes, and with all characters in UNICODE encoding.

See also

MIME.decode_words_tokenized_remapped


Method decode_words_tokenized

array(array(string)|int) MIME.decode_words_tokenized(string phrase)

Description

Tokenizes a header value just like MIME.tokenize() , but also converts encoded words using MIME.decode_word() . The result is an array where each element is either an int representing a special character, or an array as returned by decode_word() representing an atom or a quoted string.

See also

MIME.decode_words_tokenized_labled MIME.decode_words_tokenized_remapped MIME.decode_words_text


Method decode_words_tokenized_remapped

array(string|int) MIME.decode_words_tokenized_remapped(string phrase)

Description

Like MIME.decode_words_tokenized() , but the extracted atoms are also remapped from their specified character encoding into UNICODE. The result is thus identical to that of MIME.tokenize() , but without RFC1522 escapes, and with all characters in UNICODE encoding.

See also

MIME.decode_words_tokenized_labled_remapped MIME.decode_words_text_remapped


Method decode_words_tokenized_labled

array(array(string|int|array(array(string)))) MIME.decode_words_tokenized_labled(string phrase)

Description

Tokenizes and labels a header value just like MIME.tokenize_labled() , but also converts encoded words using MIME.decode_word() . The result is an array where each element is an array of two or more elements, the first being the label. The rest of the array depends on the label:

"special"

One additional element, containing the character code for the special character as an int.

"word"

Two additional elements, the first being the word, and the second being the character set of this word (or 0 if it did not originate from an encoded word).

"domain-literal"

One additional element, containing the domain literal as a string.

"comment"

One additional element, containing an array as returned by MIME.decode_words_text() .


See also

MIME.decode_words_tokenized_labled_remapped


Method decode_words_tokenized_labled_remapped

array(array(string|int)) MIME.decode_words_tokenized_labled_remapped(string phrase)

Description

Like MIME.decode_words_tokenized_labled() , but the extracted words are also remapped from their specified character encoding into UNICODE. The result is identical to that of MIME.tokenize_labled() , but without RFC1522 escapes, and with all characters in UNICODE encoding.


Method encode_words_text

string MIME.encode_words_text(array(string|array(string)) phrase, string encoding)

Description

The inverse of decode_words_text() , this function accepts an array of strings or pairs of strings which will each be encoded by encode_word() , after which they are all pasted together.

Parameter encoding

Either "base64" or "quoted-printable" (or either "b" or "q" for short).


Method encode_words_quoted

string MIME.encode_words_quoted(array(array(string)|int) phrase, string encoding)

Description

The inverse of decode_words_tokenized() , this functions accepts an array like the argument to quote() , but instead of simple strings for atoms and quoted-strings, it will also accept pairs of strings to be passed to encode_word() .

Parameter encoding

Either "base64" or "quoted-printable" (or either "b" or "q" for short).

See also

MIME.encode_words_quoted_labled()


Method encode_words_quoted_labled

string MIME.encode_words_quoted_labled(array(array(string|int|array(string|array(string)))) phrase, string encoding)

Description

The inverse of decode_words_tokenized_labled() , this functions accepts an array like the argument to quote_labled() , but "word" labled elements can optionally contain an additional string element specifying a character set, in which case an encoded-word will be used. Also, the format for "comment" labled elements is entirely different; instead of a single string, an array of strings or pairs like the first argument to encode_words_text() is expected.

Parameter encoding

Either "base64" or "quoted-printable" (or either "b" or "q" for short).

See also

MIME.encode_words_quoted()


Method guess_subtype

string MIME.guess_subtype(string type)

Description

Provide a reasonable default for the subtype field.

Some pre-RFC1521 mailers provide only a type and no subtype in the Content-Type header field. This function can be used to obtain a reasonable default subtype given the type of a message. (This is done automatically by the MIME.Message class.)

Currently, the function uses the following guesses:

"text"

"plain"

"message"

"rfc822"

"multipart"

"mixed"



Method parse_headers

array(mapping(string:string)|string) MIME.parse_headers(string message)
array(mapping(string:array(string))|string) MIME.parse_headers(string message, int(1..1) use_multiple)

Description

This is a low level function that will separate the headers from the body of an encoded message. It will also translate the headers into a mapping. It will however not try to analyze the meaning of any particular header. This means that the body is returned as is, with any transfer-encoding intact.

It is possible to call this function with just the header part of a message, in which case an empty body will be returned.

The result is returned in the form of an array containing two elements. The first element is a mapping containing the headers found. The second element is a string containing the body.

Headers that occurr multiple times will have their contents NUL separated, unless use_multiple has been specified, in which case the contents will be arrays.


Method reconstruct_partial

int|object MIME.reconstruct_partial(array(object) collection)

Description

This function will attempt to reassemble a fragmented message from its parts.

The array collection should contain MIME.Message objects forming a complete set of parts for a single fragmented message. The order of the messages in the array is not important, but every part must exist at least once.

Should the function succeed in reconstructing the original message, a new MIME.Message object will be returned.

If the function fails to reconstruct an original message, an integer indicating the reason for the failure will be returned:

0

Returned if empty collection is passed in, or one that contains messages which are not of type message/partial, or parts of different fragmented messages.

1..

If more fragments are needed to reconstruct the entire message, the number of additional messages needed is returned.

-1

If more fragments are needed, but the function can't determine exactly how many.


Note

Note that the returned message may in turn be a part of another, larger, fragmented message.

See also

MIME.Message->is_partial()


Method ext_to_media_type

string MIME.ext_to_media_type(string extension)

Description

Returns the MIME media type for the provided filename extension . Zero will be returned on unknown file extensions.

  CLASS MIME.Message

Description

This class is used to hold a decoded MIME message.


Variable headers

mapping(string:string) headers

Description

This mapping contains all the headers of the message.

The key is the header name (in lower case) and the value is the header value.

Although the mapping contains all headers, some particular headers get special treatment by the module and should not be accessed through this mapping. These fields are currently:

"content-type"
"content-disposition"
"content-length"
"content-transfer-encoding"

The contents of these fields can be accessed and/or modified through a set of variables and methods available for this purpose.

See also

type , subtype , charset , boundary , transfer_encoding , params , disposition , disp_params , setencoding() , setparam() , setdisp_param() , setcharset() , setboundary()


Variable body_parts

array(object) body_parts

Description

If the message is of type multipart, this is an array containing one Message object for each part of the message. If the message is not a multipart, this field is 0 (zero).

See also

type , boundary


Variable boundary

string boundary

Description

For multipart messages, this Content-Type parameter gives a delimiter string for separating the individual messages. As multiparts are handled internally by the module, you should not need to access this field.

See also

setboundary()


Variable charset

string charset

Description

One of the possible parameters of the Content-Type header is the charset attribute. It determines the character encoding used in bodies of type text.

If there is no Content-Type header, the value of this field is "us-ascii".

See also

type


Variable type

string type

Description

The Content-Type header contains a type, a subtype, and optionally some parameters. This field contains the type attribute extracted from the header.

If there is no Content-Type header, the value of this field is "text".

See also

subtype , params


Variable subtype

string subtype

Description

The Content-Type header contains a type, a subtype, and optionally some parameters. This field contains the subtype attribute extracted from the header.

If there is no Content-Type header, the value of this field is "plain".

See also

type , params


Variable transfer_encoding

string transfer_encoding

Description

The contents of the Content-Transfer-Encoding header.

If no Content-Transfer-Encoding header is given, this field is 0 (zero).

Transfer encoding and decoding is done transparently by the module, so this field should be interesting only to applications wishing to do auto conversion of certain transfer encodings.

See also

setencoding()


Variable params

mapping(string:string) params

Description

A mapping containing all the additional parameters to the Content-Type header.

Some of these parameters have fields of their own, which should be accessed instead of this mapping wherever applicable.

See also

charset , boundary , setparam()


Variable disposition

string disposition

Description

The first part of the Content-Disposition header, hinting on how this part of a multipart message should be presented in an interactive application.

If there is no Content-Disposition header, this field is 0.


Variable disp_params

mapping(string:string) disp_params

Description

A mapping containing all the additional parameters to the Content-Disposition header.

See also

setdisp_param() , get_filename()


Method get_filename

string get_filename()

Description

This method tries to find a suitable filename should you want to save the body data to disk.

It will examine the filename attribute of the Content-Disposition header, and failing that the name attribute of the Content-Type header. If neither attribute is set, the method returns 0.

Note

An interactive application should always query the user for the actual filename to use. This method may provide a reasonable default though.


Method is_partial

array(string|int) is_partial()

Description

If this message is a part of a fragmented message (i.e. has a Content-Type of message/partial), an array with three elements is returned.

The first element is an identifier string. This string should be used to group this message with the other fragments of the message (which will have the same id string).

The second element is the sequence number of this fragment. The first part will have number 1, the next number 2 etc.

The third element of the array is either the total number of fragments that the original message has been split into, or 0 of this information is not available.

If this method is called in a message that is not a part of a fragmented message, it will return 0.

See also

MIME.reconstruct_partial()


Method setdata

void setdata(string data)

Description

Replaces the body entity of the data with a new piece of raw data.

The new data should comply to the format indicated by the type and subtype attributes.

Note

Do not use this method unless you know what you are doing.

See also

getdata()


Method getdata

string getdata()

Description

This method returns the raw data of the message body entity.

The type and subtype attributes indicate how this data should be interpreted.

See also

getencoded()


Method getencoded

string getencoded()

Description

This method returns the data of the message body entity, encoded using the current transfer encoding.

You should never have to call this function.

See also

getdata()


Method setencoding

void setencoding(string encoding)

Description

Select a new transfer encoding for this message.

The Content-Transfer-Encoding header will be modified accordingly, and subsequent calls to getencoded will produce data encoded using the new encoding.

See MIME.encode() for a list of valid encodings.

See also

getencoded() , MIME.encode()


Method setparam

void setparam(string param, string value)

Description

Set or modify the named parameter of the Content-Type header.

Common parameters include charset for text messages, and boundary for multipart messages.

Note

It is not allowed to modify the Content-Type header directly, please use this function instead.

See also

setcharset() , setboundary() , setdisp_param()


Method setdisp_param

void setdisp_param(string param, string value)

Description

Set or modify the named parameter of the Content-Disposition header.

A common parameters is e.g. filename.

Note

It is not allowed to modify the Content-Disposition header directly, please use this function instead.

See also

setparam() , get_filename()


Method setcharset

void setcharset(string charset)

Description

Sets the charset parameter of the Content-Type header.

This is equivalent of calling

setparam("charset", charset )
.

See also

setparam()


Method setboundary

void setboundary(string boundary)

Description

Sets the boundary parameter of the Content-Type header.

This is equivalent of calling

setparam("boundary", boundary )
.

See also

setparam()


Method cast

string cast(string dest_type)

Description

Casting the message object to a string will yield a byte stream suitable for transmitting the message over protocols such as ESMTP and NNTP.

The body will be encoded using the current transfer encoding, and subparts of a multipart will be collected recursively. If the message is a multipart and no boundary string has been set, one will be generated using generate_boundary() .

See also

create()


Method create

void MIME.Message()
void MIME.Message(string message)
void MIME.Message(string message, mapping(string:string|array(string)) headers, array(object)|void parts)
void MIME.Message(string message, mapping(string:string|array(string)) headers, array(object)|void parts, int(0..1) guess)

Description

There are several ways to call the constructor of the Message class:

  • With zero arguments, you will get a dummy message with neither headers nor body. Not very useful.

  • With one argument, the argument is taken to be a byte stream containing a message in encoded form. The constructor will analyze the string and extract headers and body.

  • With two or three arguments, the first argument is taken to be the raw body data, and the second argument a desired set of headers. The keys of this mapping are not case-sensitive. If the given headers indicate that the message should be of type multipart, an array of Message objects constituting the subparts should be given as a third argument.

  • With the guess argument set to 1 (headers and parts may be 0 if you don't want to give any), you get a more forgiving MIME Message that will do its best to guess what broken input data really meant. It won't always guess right, but for applications like mail archives and similar where you can't get away with throwing an error at the user, this comes in handy. Only use the guess mode only for situations where you need to process broken MIME messages silently; the abuse of overly lax tools is what poisons standards.

See also

cast()

  Module Math


Inherit "___predef::"

inherit "___predef::"


Method convert_angle

int|float Math.convert_angle(int|float angle, string from, string to)

Description

This function converts between degrees, radians and gons. The from and to arguments may be any of the follwoing strings: "deg", "rad", "gon" and "str" for degrees, radians, gon and streck respectivly. The output is not guaranteed to be within the first turn, e.g. converting 10 radians yields almost 573 degrees as output.

  CLASS Math.SMatrix

Description

These classes hold Matrix capabilites, and support a range of matrix operations.

Matrix only handles double precision floating point values FMatrix only handles single precision floating point values LMatrix only handles integers (64 bit) IMatrix only handles integers (32 bit) SMatrix only handles integers (16 bit)


Method `+
Method ``+
Method add

Matrix `+(object with)
Matrix ``+(object with)
Matrix add(object with)

Description

Add this matrix to another matrix. A new matrix is returned. The matrices must have the same size.


Method cast

array(array) cast(string to_what)
array(array) cast(string to_what)

Description

This is to be able to get the matrix values. (array) gives back a double array of floats. m->vect() gives back an array of floats.


Method convolve

Matrix convolve(object with)

Description

Convolve called matrix with the argument.


Method create

void Math.SMatrix(array(array(int|float)) 2d_matrix)
void Math.SMatrix(array(int|float) 1d_matrix)
void Math.SMatrix(int n, int m)
void Math.SMatrix(int n, int m, string type)
void Math.SMatrix(int n, int m, float|int init)
void Math.SMatrix("identity", int size)
void Math.SMatrix("rotate", int size, float rads, Matrix axis)
void Math.SMatrix("rotate", int size, float rads, float x, float y, float z)

Description

This method initializes the matrix. It is illegal to create and hold an empty matrix.

The normal operation is to create the matrix object with a double array, like Math.Matrix( ({({1,2}),({3,4})}) ).

Another use is to create a special type of matrix, and this is told as third argument.

Currently there are only the "identity" type, which gives a matrix of zeroes except in the diagonal, where the number one (1.0) is. This is the default, too.

The third use is to give all indices in the matrix the same value, for instance zero or 42.

The forth use is some special matrixes. First the square identity matrix again, then the rotation matrix.


Method cross
Method
Method ``×

Matrix cross(object with)
Matrix (object with)
Matrix ``×(object with)

Description

Matrix cross-multiplication.


Method dot_product
Method
Method ``·

float dot_product(object with)
float (object with)
float ``·(object with)

Description

Matrix dot product.


Method max
Method min

Matrix max()
Matrix min()

Description

Produces the maximum or minimum value of all the elements in the matrix.


Method `*
Method ``*
Method mult

Matrix `*(object with)
Matrix ``*(object with)
Matrix mult(object with)

Description

Matrix multiplication.


Method norm
Method norm2
Method normv

float norm()
float norm2()
Matrix normv()

Description

Norm of the matrix, and the square of the norm of the matrix. (The later method is because you may skip a square root sometimes.)

This equals |A| or sqrt( A02 + A12 + ... + An2 ).

It is only usable with 1xn or nx1 matrices.

m->normv() is equal to m*(1.0/m->norm()), with the exception that the zero vector will still be the zero vector (no error).


Method `-
Method ``-
Method sub

Matrix `-()
Matrix `-(object with)
Matrix ``-(object with)
Matrix sub(object with)

Description

Subtracts this matrix from another. A new matrix is returned. -m is equal to -1*m.


Method sum

Matrix sum()

Description

Produces the sum of all the elements in the matrix.


Method transpose

Matrix transpose()

Description

Transpose of the matrix as a new object.


Method vect

array vect()

Description

Return all the elements of the matrix as an array of numbers

  CLASS Math.Angle

Description

Represents an angle.


Variable angle

int|float angle

Description

The actual keeper of the angle value.


Variable type

string type

Description

The type of the angle value. Is either "deg", "rad", "gon" or "str".


Method create

void Math.Angle()
void Math.Angle(int|float radians)
void Math.Angle(int|float angle, string type)

Description

If an angle object is created without arguments it will have the value 0 radians.


Method clone_me

Angle clone_me()

Description

Returns a copy of the object.


Method get

int|float get(string type)

Description

Gets the value in the provided type.


Method set

Angle set(string type, int|float _angle)

Description

Sets the angle value and type to the given value and type.


Method normalize

void normalize()

Description

Normalizes the angle to be within one turn.


Method degree

int|float degree()

Description

Returns the number of degrees, including minutes and seconds as decimals.


Method minute

int minute()

Description

Returns the number of minute.


Method second

float second()

Description

Returns the number of seconds.


Method set_dms

Angle set_dms(int degrees)
Angle set_dms(int degrees, int minutes)
Angle set_dms(int degrees, inte minutes, float seconds)

Description

Set degrees, minues and seconds. Returns the current angle object.


Method format_dms

string format_dms()

Description

Returns degrees, minutes and seconds as a string, e.g. 47°6'36.00".


Method set_degree

Angle set_degree(int|float degree)

Description

Sets the angle to the provided degree. Alters the type to degrees. Returns the current object.


Method gon

int|float gon()

Description

Returns the number of gons.


Method set_gon

Angle set_gon(int|float gon)

Description

Set the angle to the provided gons. Alters the type to gons. Returns the current angle object.


Method rad

float rad()

Description

Returns the number of radians.


Method set_rad

Angle set_rad(int|float rad)

Description

Set the angle to the provided radians. Alters the type to radians. Returns the current angle object.


Method streck

float|int streck()

Description

Returns the number of strecks.


Method set_streck

Angle set_streck(int|float str)

Description

Set the angle to the provided strecks. Alters the type to streck. Returns the current angle object.


Method about_face

void about_face()

Description

Turns the direction of the angle half a turn. Equal to

add(180,"deg")
.


Method right_face

void right_face()

Description

Turns the direction of the angle a quarter of a turn to the right. Equal to

subtract(90,"deg")
.


Method left_face

void left_face()

Description

Turns the direction of the angle a quarter of a turn to the left. Equal to

add(90,"deg")
.


Method sin

float sin()

Description

Returns the sinus for the angle.


Method cos

float cos()

Description

Returns the cosinus for the angle.


Method tan

float tan()

Description

Returns the tangen for the angle.


Method cast

float|int|string cast(string to)

Description

An angle can be casted to float, int and string.


Method `+

float|int|Angle `+(float|int|Angle _angle)

Description

Returns the sum of this angle and what it is added with. If added with an angle, a new angle object is returnes.


Method add

Angle add(float|int angle)
Angle add(float|int angle, string type)
Angle add(Angle angle)

Description

Adds the provided angle to the current angle. The result is normalized within 360 degrees.


Method `-

float|int|Angle `-(float|int|Angle _angle)

Description

Returns the difference between this angle and the provided value. If differenced with an angle, a new angle object is returned.


Method subtract

Angle subtract(float|int angle)
Angle subtract(float|int angle, string type)
Angle subtract(Angle angle)

Description

Subtracts the provided angle from the current angle. The result is normalized within 360 degrees.


Method `*

float|int|Angle `*(float|int|Angle _angle)

Description

Returns the product between this angle and the provided value. If differenced with an angle, a new angle object is returned.


Method `/

float|int|Angle `/(float|int|Angle _angle)

Description

Returns the fraction between this angle and the provided value. If differenced with an angle, a new angle object is returned.


Method `%

float|int|Angle `%(float|int|Angle _angle)

Description

Returns this result of this angle modulo the provided value. If differenced with an angle, a new angle object is returned.


Method __hash

int __hash()


Method `==

int `==(Angle _angle)

Description

Compares the unnormalized angle of two Angle objects.


Method `<

int `<(Angle _angle)

Description

Compares the unnormalized angle of two Angle objects.


Method `>

int `>(Angle _angle)

Description

Compares the unnormalized angle of two Angle objects.

  Module Math.Transforms

  CLASS Math.Transforms.FFT


Method rFFT

array(array(float)) rFFT(array(int|float) real_input)

Description

Returns the FFT of the input array. The input must be real and the output is complex. The output consists of an array. It's first element is the amplitudes and the second element is the phases.

Parameter real_input

The array of floats and/or ints to transform.

Note

rIFFT(rFFT()) returns the input array scaled by n=sizeof(input array). This is due to the nature of the DFT algorithm.

See also

rIFFT()


Method rIFFT

array(float) rIFFT(array(array(float)) input)

Description

Returns the inverse FFT of the input array. The input must be complex and guaranteed to generate a real output.

The input is an array. It's first element is the amplitudes and the second element is the phases.

The output is an array of the real values for the iFFT.

Parameter real_input

The array of floats and/or ints to transform.

Note

rIFFT(rFFT()) returns the input array scaled by n=sizeof(input array). This is due to the nature of the DFT algorithm.

See also

rFFT()


Method create

void Math.Transforms.FFT(void|int n, void|int(0..1) exact)

Description

Creates a new transform object. If n is specified, a plan is created for transformations of n-size arrays.

Parameter n

Size of the transform to be preformed. Note that the transform object will be initialized for this size, but if an array of different size is sent to the object, it will be reinitialized. This can be used to gain preformace if all transforms will be of a given size.

Parameter exact

If exact is 1, a "better" plan for the transform will be created. This will take more time though. Use only if preformance is needed.

  Module Msql

Description

This is an interface to the mSQL database server. This module may or may not be availible on your Pike, depending whether the appropriate include and library files (msql.h and libmsql.a respectively) could be found at compile-time. Note that you do not need to have a mSQL server running on your host to use this module: you can connect to the database over a TCP/IP socket

Please notice that unless you wish to specifically connect to a mSQL server, you'd better use the Sql.Sql program instead. Using Sql.Sql ensures that your Pike applications will run with any supported SQL server without changing a single line of code.

Also notice that some functions may be mSQL/2.0-specific, and thus missing on hosts running mSQL/1.0.*

Note

The mSQL C API has some extermal dependencies. They take the form of certain environment variables which, if defined in the environment of the pike interpreter, influence the interface's behavior. Those are "MSQL_TCP_PORT" which forces the server to connect to a port other than the default, "MSQL_UNIX_PORT", same as above, only referring to the UNIX domain sockets. If you built your mSQL server with the default setttings, you shouldn't worry about these. The variable MINERVA_DEBUG can be used to debug the mSQL API (you shouldn't worry about this either). Refer to the mSQL documentation for further details.

Also note that THIS MODULE USES BLOCKING I/O to connect to the server. mSQL should be reasonably fast, but you might want to consider this particular aspect. It is thread-safe, and so it can be used in a multithread environment.

FIXME

Although it seems that mSQL/2.0 has some support for server statistics, it's really VERY VERY primitive, so it won't be added for now.

See also

Sql.Sql


Constant version

constant Msql.version

Description

Should you need to report a bug to the author, please submit along with the report the driver version number, as returned by this call.

  CLASS Msql.msql


Method shutdown

void shutdown()

Description

This function shuts a SQL-server down.


Method reload_acl

void reload_acl()

Description

This function forces a server to reload its ACLs.

Note

This function is not part of the standard interface, so it is not availible through the Sql.Sql interface, but only through Sql.msql and Msql.msql programs.

See also

create


Method create

void Msql.msql(void|string dbserver, void|string dbname, void|string username, void|string passwd)

Description

With one argument, this function tries to connect to the specified (use hostname or IP address) database server. To connect to a server running on the local host via UNIX domain sockets use "localhost". To connect to the local host via TCP/IP sockets you have to use the IP address "127.0.0.1". With two arguments it also selects a database to use on the server. With no arguments it tries to connect to the server on localhost, using UNIX sockets.

Throws

You need to have a database selected before using the sql-object, otherwise you'll get exceptions when you try to query it. Also notice that this function can raise exceptions if the db server doesn't respond, if the database doesn't exist or is not accessible by you.

Note

You don't need bothering about syncronizing the connection to the database: it is automatically closed (and the database is sync-ed) when the msql object is destroyed.

See also

select_db


Method list_dbs

array list_dbs(void|string wild)

Description

Returns an array containing the names of all databases availible on the system. Will throw an exception if there is no server connected. If an argument is specified, it will return only those databases whose name matches the given glob.


Method list_tables

array list_tables(void|string wild)

Description

Returns an array containing the names of all the tables in the currently selected database. Will throw an exception if we aren't connected to a database. If an argument is specified, it will return only those tables whose name matches the given glob.


Method select_db

void select_db(string dbname)

Description

Before querying a database you have to select it. This can be accomplished in two ways: the first is calling the create function with two arguments, another is calling it with one or no argument and then calling select_db . You can also use this function to change the database you're querying, as long as it is on the same server you are connected to.

Throws

This function CAN raise exceptions in case something goes wrong (for example: unexistant database, insufficient permissions, whatever).

See also

create , error


Method query

array(mapping(string:mixed)) query(string sqlquery)

Description

This is all you need to query the database. It takes as argument an SQL query string (i.e.: "SELECT foo,bar FROM baz WHERE name like '%kinkie%'" or "INSERT INTO baz VALUES ('kinkie','made','this')") and returns a data structure containing the returned values. The structure is an array (one entry for each returned row) of mappings which have the column name as index and the column contents as data. So to access a result from the first example you would have to do "results[0]->foo".

A query which returns no data results in an empty array (and NOT in a 0). Also notice that when there is a column name clash (that is: when you join two or more tables which have columns with the same name), the clashing columns are renamed to <tablename>+"."+<column name>. To access those you'll have to use the indexing operator '[] (i.e.: results[0]["foo.bar"]).

Throws

Errors (both from the interface and the SQL server) are reported via exceptions, and you definitely want to catch them. Error messages are not particularly verbose, since they account only for errors inside the driver. To get server-related error messages, you have to use the error function.

Note

Note that if the query is NOT a of SELECT type, but UPDATE or MODIFY, the returned value is an empty array. This is not an error. Errors are reported only via exceptions.

See also

error


Method server_info

string server_info()

Description

This function returns a string describing the server we are talking to. It has the form "servername/serverversion" (like the HTTP protocol description) and is most useful in conjunction with the generic SQL-server module.


Method host_info

string host_info()

Description

This function returns a string describing what host are we talking to, and how (TCP/IP or UNIX sockets).


Method error

string error()

Description

This function returns the textual description of the last server-related error. Returns 0 if no error has occurred yet. It is not cleared upon reading (can be invoked multiple times, will return the same result until a new error occurs).

See also

query


Method create_db

void create_db(string dbname)

Description

This function creates a new database with the given name (assuming we have enough permissions to do this).

See also

drop_db


Method drop_db

void drop_db(string dbname)

Description

This function destroys a database and all the data it contains (assuming we have enough permissions to do so). USE WITH CAUTION!

See also

create_db


Method list_fields

mapping(string:mapping(string:mixed)) list_fields(string table, void|string glob)

Description

Returns a mapping describing the fields of a table in the database. The returned value is a mapping, indexed on the column name, of mappings.The glob argument, if present, filters out the fields not matching the glob. These contain currently the fields:

"type" : string

Describes the field's mSQL data type ("char","integer",...)

"length" : int

It describes the field's length. It is only interesting for char() fields, in fact. Also notice that the strings returned by msql->query() have the correct length. This field only specifies the _maximum_ length a "char()" field can have.

"table" : string

The table this field is in. Added only for interface compliancy.

"flags" : multiset(string)

It's a multiset containing textual descriptions of the server's flags associated with the current field. Currently it can be empty, or contain "unique" or "not null".


Note

The version of this function in the Msql.msql() program is not sql-interface compliant (this is the main reason why using that program directly is deprecated). Use Sql.Sql instead.

See also

query


Method affected_rows

int affected_rows()

Description

This function returns how many rows in the database were affected by our last SQL query.

Note

This function is availible only if you're using mSQL version 2 or later. (That means: if the includes and library of version 2 of mSQL were availible when the module was compiled).

This function is not part of the standard interface, so it is not availible through the Sql.Sql interface, but only through Sql.msql and Msql.msql programs


Method list_index

array list_index(string tablename, string indexname)

Description

This function returns an array describing the index structure for the given table and index name, as defined by the non-standard SQL query 'create index' (see the mSQL documentation for further informations). More than one index can be created for a table. There's currently NO way to have a listing of the indexes defined for a table (blame it on the mSQL API).

Note

This function is availible if you're using mSQL version 2 or later.

This function is not part of the standard interface, so it is not availible through the Sql.Sql interface, but only through Sql.msql and Msql.msql programs.

  Module PDF


constant PDF.a0_width
constant PDF.a0_height
constant PDF.a1_width
constant PDF.a1_height
constant PDF.a2_width
constant PDF.a2_height
constant PDF.a3_width
constant PDF.a3_height
constant PDF.a4_width
constant PDF.a4_height
constant PDF.a5_width
constant PDF.a5_height
constant PDF.a6_width
constant PDF.a6_height
constant PDF.b5_width
constant PDF.b5_height
constant PDF.letter_width
constant PDF.letter_height
constant PDF.legal_width
constant PDF.legal_height
constant PDF.ledger_width
constant PDF.ledger_height
constant PDF.p11x17_width
constant PDF.p11x17_height

  CLASS PDF.PDFgen


Method open_file

int open_file(string filename)


Method close

PDF close()


Method begin_page

PDF begin_page()
PDF begin_page(float width, float height)

Description

note: Defaults to a4, portrait


Method end_page

PDF end_page()


Method get_value

float get_value(string key)
float get_value(string key, float modifier)


Method set_value

float set_value(string key, float value)


Method get_parameter

string get_parameter(string key)
string get_parameter(string key, float modifier)


Method set_parameter

float set_parameter(string key, string parameter)


Method set_info

float set_info(string key, string info)


Method findfont

int findfont(string fontname)
int findfont(string fontname, void|string encoding, void|int embed)


Method setfont

PDF setfont(int n, float size)


Method show

PDF show(string s)


Method showxy

PDF showxy(string s, float x, float y)


Method continue_text

PDF continue_text(string s)


Method show_boxed

int show_boxed(string text, float x, float y, float width, float height, string mode)
int show_boxed(string text, float x, float y, float width, float height, string mode, string feature)


Method stringwidth

float stringwidth(string text, int font, float size)


Method set_text_pos

object set_text_pos(float x, float y)


Method setdash

object setdash(float b, float w)


Method setflat

object setflat(float flatness)


Method setlinejoin

object setlinejoin(int linejoin)


Method setlinecap

object setlinecap(int linecap)


Method setmiterlimit

object setmiterlimit(float miter)


Method setlinewidth

object setlinewidth(float width)


Method translate

object translate(float tx, float ty)


Method scale

object scale(float sx, float sy)


Method rotate

object rotate(float phi)


Method skew

object skew(float alpha, float beta)


Method concat

object concat(float a, float b, float c, float d, float e, float f)


Method moveto

object moveto(float x, float y)


Method lineto

object lineto(float x, float y)


Method curveto

object curveto(float x1, float y1, float x2, float y2, float x3, float y3)


Method circle

object circle(float x, float y, float r)


Method arc

object arc(float x, float y, float r, float start, float end)


Method rect

object rect(float x, float y, float width, float height)


Method setgray_fill

object setgray_fill(float gray)


Method setgray_stroke

object setgray_stroke(float gray)


Method setgray

object setgray(float gray)


Method setrgbcolor_fill

object setrgbcolor_fill(float red, float green, float blue)


Method setrgbcolor_stroke

object setrgbcolor_stroke(float red, float green, float blue)


Method setrgbcolor

object setrgbcolor(float red, float green, float blue)


Method open_image_file

int open_image_file(string type, string filename)
int open_image_file(string type, string filename, void|string stringparam, void|int intparam)


Method open_CCITT

int open_CCITT(string filename, int width, int height, int BitReverse, int K, int BlackIs1)


Method open_image

int open_image(string type, string source, string data, int width, int height, int components, int bpc, string params)


Method close_image

object close_image(int image)


Method place_image

object place_image(int image, float x, float y, float scale)


Method add_bookmark

int add_bookmark(string text, int parent, int open)


Method attach_file

object attach_file(float llx, float lly, float urx, float ury, string filename, string description, string author, string mimetype, string icon)


Method add_pdflink

object add_pdflink(float llx, float lly, float urx, float ury, string filename, int page, string dest)


Method add_locallink

object add_locallink(float llx, float lly, float urx, float ury, int page, string dest)


Method add_launchlink

object add_launchlink(float llx, float lly, float urx, float ury, string filename)


Method add_weblink

object add_weblink(float llx, float lly, float urx, float ury, string url)


Method set_border_style

object set_border_style(string style, float width)


Method set_border_color

object set_border_color(float red, float green, float blue)


Method set_border_dash

object set_border_dash(float b, float w)

  Module Perl

Description

This module allows access to an embedded Perl interpreter, if a libperl.so (or equivalent) was found during the installation of Pike.

  CLASS Perl.Perl

Description

An object of this class is a Perl interpreter.


Method create

void Perl.Perl()

Description

Create a Perl interpreter object. There can only be one Perl interpreter object at the same time, unless Perl was compiled with the MULTIPLICITY option, and Pike managed to figure this out during installation. An error will be thrown if no Perl interpreter is available.


Method parse

int parse(array(string) args)
int parse(array(string) args, mapping(string:string) env)

Description

Parse a Perl script file and set up argument and environment for it. Returns zero on success, and non-zero if the parsing failed.

Parameter args

Arguments in the style of argv, i.e. with the name of the script first.

Parameter env

Environment mapping, mapping environment variable names to to their values.


Method run

int run()

Description

Run a previously parsed Perl script file. Returns a status code.


Method eval

mixed eval(string expression)

Description

Evalute a Perl expression in a scalar context, and return the result if it is a simple value type. Unsupported value types are rendered as 0.


Method eval_list

mixed eval_list(string expression)

Description

Evalute a Perl expression in a list context, and return the result if it is a simple value type, or an array of simple value types. Unsupported value types are rendered as 0.


Method call

mixed call(string name, mixed ... arguments)

Description

Call a Perl subroutine in a scalar context, and return the result if it is a simple value type. Unsupported value types are rendered as 0.

Parameter name

The name of the subroutine to call, as an 8-bit string.

Parameter arguments

Zero or more arguments to the function. Only simple value types are supported. Unsupported value types will cause an error to be thrown.


Method call_list

mixed call_list(string name, mixed ... arguments)

Description

Call a Perl subroutine in a list context, and return the result if it is a simple value type, or an array of simple value types. Unsupported value types are rendered as 0.

Parameter name

The name of the subroutine to call, as an 8-bit string.

Parameter arguments

Zero or more arguments to the function. Only simple value types are supported. Unsupported value types will cause an error to be thrown.


Method get_scalar

mixed get_scalar(string name)

Description

Get the value of a Perl scalar variable. Returns the value, or a plain 0 if the value type was not supported.

Parameter name

Name of the scalar variable, as an 8-bit string.


Method set_scalar

void set_scalar(string name, mixed value)

Description

Set the value of a Perl scalar variable.

Parameter name

Name of the scalar variable, as an 8-bit string.

Parameter value

The new value. Only simple value types are supported. Throws an error for unsupported value types.


Method get_array_item

mixed get_array_item(string name, int index)

Description

Get the value of an entry in a Perl array variable. Returns the value, or a zero-type value if indexing outside the array, or a plain zero if the value type was not supported.

Parameter name

Name of the array variable, as an 8-bit string.

Parameter index

Array index. An error is thrown if the index is negative, non-integer or a bignum.


Method set_array_item

void set_array_item(string name, int index, mixed value)

Description

Set the value of an entry in a Perl array variable. Only simple value types are supported. Throws an error for unsupported value types.

Parameter name

Name of the array variable, as an 8-bit string.

Parameter index

Array index. An error is thrown if the index is negative, non-integer or a bignum.

Parameter value

New value. Only simple value types are supported. An error is thrown for unsupported value types.


Method get_hash_item

mixed get_hash_item(string name, mixed key)

Description

Get the value of an entry in a Perl hash variable. Returns the value, or a zero-type value if the hash had no entry for the given key, or a plain 0 if the returned value type was not supported.

Parameter name

Name of the array variable, as an 8-bit string.

Parameter key

Hash key. Only simple value types are supported. An error is thrown for unsupported value types.


Method set_hash_item

void set_hash_item(string name, mixed key, mixed value)

Description

Set the value of an entry in a Perl hash variable.

Parameter name

Name of the hash variable, as an 8-bit string.

Parameter key

Hash key. Only simple value types are supported. An error is thrown for unsupported value types.

Parameter value

New value. Only simple value types are supported. An error is thrown for unsupported value types.


Method array_size

int array_size(string name)

Description

Get the size of the Perl array variable with the given name.

Parameter name

Name of the array variable, as an 8-bit string.


Method get_array

array get_array(string name)

Description

Get the contents of a Perl array variable as a Pike array. If the size of the array is larger than the specified array size limit, the returned Pike array will be truncated according to the limit.

Parameter name

Name of the array variable, as an 8-bit string.

See also

array_size_limit()


Method get_hash_keys

array get_hash_keys(string name)

Description

Get the keys (indices) of a Perl hash variable as a Pike array. If the size of the resulting array is larger than the specified array size limit, an error will be thrown.

Parameter name

Name of the hash variable, as an 8-bit string.

See also

array_size_limit()


Method array_size_limit

int array_size_limit()
int array_size_limit(int limit)

Description

Get (and optionally set) the array size limit for this interpreter instance. Without arguments, the current limit is returned. With an integer argument, the limit is set to that value, and the same value is returned.

The array size limit is mainly a way of ensuring that there isn't a sudden explosion in memory usage and data conversion time in this embedding interface. There is no particular limit other than available memory in Perl itself.

Note

The default array size limit is 500 elements, but this may change in future releases of Pike.

The maximum array size limit is the highest number representable as a non-bignum integer (which is typically 2147483647 on a traditional 32-bit architecture).

Parameter limit

The new array size limit.

  Module Regexp

Description

This module implements the interface to a simple regexp engine with the following capabilities:

.Matches any character.
[abc]Matches a, b or c.
[a-z]Matches any character a to z inclusive.
[^ac]Matches any character except a and c.
(x)Matches x (x might be any regexp) If used with split, this also puts the string matching x into the result array.
x*Matches zero or more occurances of 'x' (x may be any regexp).
x+Matches one or more occurances of 'x' (x may be any regexp).
x|yMatches x or y. (x or y may be any regexp).
xyMatches xy (x and y may be any regexp).
^Matches beginning of string (but no characters).
$Matches end of string (but no characters).
\<Matches the beginning of a word (but no characters).
\>Matches the end of a word (but no characters).

Note that \ can be used to quote these characters in which case they match themselves, nothing else. Also note that when quoting these something in Pike you need two \ because Pike also uses this character for quoting.


Method create

void Regexp.(string re)

Description

When create is called, the current regexp bound to this object is cleared. If a string is sent to create(), this string will be compiled to an internal representation of the regexp and bound to this object for laters calls to match or split. Calling create() without an argument can be used to free up a little memory after the regexp has been used.


Method match

int Regexp.match(string str)

Description

Returns 1 if str matches the regexp bound to the regexp object. Zero otherwise.


Method match

array(string) Regexp.match(array(string) strs)

Description

Returns an array containing strings in strs that match the regexp bound to the regexp object.

Bugs

The current implementation (Pike 7.3.51) doesn't support searching in strings containing the NUL character or any wide character.

See also

split


Method split

array(string) Regexp.split(string s)

Description

Works as match , but returns an array of the strings that matched the subregexps. Subregexps are those contained in "( )" in the regexp. Subregexps that were not matched will contain zero. If the total regexp didn't match, zero is returned.

Bugs

You can currently only have 39 subregexps.

Bugs

The current implementation (Pike 7.3.51) doesn't support searching in strings containing the NUL character or any wide character.

See also

match

  Module SANE

Description

This module enables access to the SANE (Scanner Access Now Easy) library from pike


Method list_scanners

array(mapping) SANE.list_scanners()

Description

Returns an array with all available scanners.

Example

Pike v0.7 release 120 running Hilfe v2.0 (Incremental Pike Frontend) > SANE.list_scanners(); Result: ({ ([ "model":"Astra 1220S ", "name":"umax:/dev/scg1f", "type":"flatbed scanner", "vendor":"UMAX " ]), ([ "model":"Astra 1220S ", "name":"net:lain.idonex.se:umax:/dev/scg1f", "type":"flatbed scanner", "vendor":"UMAX " ]) })


syntax

constant SANE.FrameGray
constant SANE.FrameRGB
constant SANE.FrameRed
constant SANE.FrameGreencosntant SANE.FrameBlue

  CLASS SANE.Scanner


Method create

void SANE.Scanner(string name)


Method list_options

array(mapping) list_options()

Description

This method returns an array where every element is a mapping, layed out as follows.

"name" : string 
"title" : string 
"desc" : string 
"type" : string
"boolean"
"int"
"float"
"string"
"button"
"group"

"unit" : string
"none"
"pixel"
"bit"
"mm"
"dpi"
"percent"
"microsend"

"size" : int 
"cap" : multiset
"soft_select"
"hard_select"
"emulate"
"automatic"
"inactive"
"advanced"

"constraint" : int(0..0)|mapping

Constraints can be of three different types; range, word list or string list. Constraint contains 0 if there are no constraints.

"type" : string

Contains the value "range".

"max" : int 
"min" : int 
"quant" : int 

"type" : string

Contains the value "list".

"list" : array(float|int) 

"type" : string

Contains the value "list".

"list" : array(string) 



Method set_option

void set_option(string name, mixed new_value)
void set_option(string name)

Description

If no value is specified, the option is set to it's default value


Method get_option

mixed get_option(string name)


Method get_parameters

mapping(string:int) get_parameters()

Returns
"format" : int
"last_frame" : int
"lines" : int
"depth" : int
"pixels_per_line" : int
"bytes_per_line" : int


Method simple_scan

Image.Image simple_scan()


Method row_scan

void row_scan(function(Image.Image:void) callback)


Method nonblocking_row_scan

void nonblocking_row_scan(function(Image.Image:void) callback)


Method cancel_scan

void cancel_scan()

  Module Yp

Description

This module is an interface to the Yellow Pages functions. Yp is also known as NIS (Network Information System) and is most commonly used to distribute passwords and similar information within a network.


Inherit "___predef::"

inherit "___predef::"


Method default_domain

string Yp.default_domain()

Description

Returns the default yp-domain.

  CLASS Yp.Map

Description

Network Information Service aka YP map.


Method create

void Yp.Map(string map, string|void domain)

Description

Create a new YP-map object.

map is the YP-map to bind to. This may be a nickname, such as passwd instead of just passwd.byname.

If domain is not specified, the default domain will be used.

Note

If there is no YP server available for the domain, this function call will block until there is one. If no server appears in about ten minutes or so, an error will be returned. The timeout is not configurable.


Method match
Method `[]

string match(string key)
string `[](string key)

Description

Search for the key key . If there is no key in the map, 0 (zero) will be returned, otherwise the string matching the key will be returned.

Note

key must match exactly, no pattern matching of any kind is done.


Method all
Method cast_to_mapping

mapping(string:string) all()
mapping(string:string) cast_to_mapping()

Description

Returns the whole map as a mapping.


Method map

void map(function(string:void) fun)

Description

Call a function for each entry in the map.

For each entry in the map, call the function fun .

The function will be called like void fun(string key, string value).


Method server

string server()

Description

Return the server that provides this map.


Method order

int order()

Description

Return the order number for this map.


Method _sizeof

int _sizeof()

Description

Return the number of entries in this map.


Method _indices

array(string) _indices()

Description

Return the keys of the map.


Method _values

array(string) _values()

Description

Return the values of the map.

  CLASS Yp.Domain


Method server

string server(string map)

Description

Returns the hostname of the server serving the map map . map is the YP-map to search in. This must be the full map name. eg passwd.byname instead of just passwd.


Method create
Method bind

void Yp.Domain(string|void domain)
void bind(string domain)

Description

If domain is not specified , the default domain will be used. (As returned by Yp.default_domain() ).

If there is no YP server available for the domain, this function call will block until there is one. If no server appears in about ten minutes or so, an error will be returned. This timeout is not configurable.

See also

Yp.default_domain()


Method all

mapping(string:string) all(string map)

Description

Returns the whole map as a mapping.

map is the YP-map to search in. This must be the full map name, you have to use passwd.byname instead of just passwd.


Method map

void map(string map, function(string:void) fun)

Description

For each entry in map , call the function specified by fun .

fun will get two arguments, the first being the key, and the second the value.

map is the YP-map to search in. This must be the full map name. eg passwd.byname instead of just passwd.


Method order

int order(string map)

Description

Returns the 'order' number for the map map .

This is usually the number of seconds since Jan 1 1970 (see time() ). When the map is changed, this number will change as well.

map is the YP-map to search in. This must be the full map name. eg passwd.byname instead of just passwd.


Method match

string match(string map, string key)

Description

Search for the key key in the Yp-map map .

Returns

If there is no key in the map, 0 (zero) will be returned, otherwise the string matching the key will be returned.

Note

key must match exactly, no pattern matching of any kind is done.

  Module Crypto


Method string_to_hex

string Crypto.string_to_hex(string data)

Description

Convert a string of binary data to a hexadecimal string.

See also

hex_to_string()


Method hex_to_string

string Crypto.hex_to_string(string hex)

Description

Convert a string of hexadecimal digits to binary data.

See also

string_to_hex()


Method des_parity

string Crypto.des_parity(string raw)

Description

Adjust the parity for a string so that it is acceptable according to DES.


Method crypt_md5

string Crypto.crypt_md5(string password)
string Crypto.crypt_md5(string password, string salt)

Description

This function crypts a password with an algorithm based on MD5 hashing.

If salt is left out, an 8 character long salt (max length) will be randomized.

Verification can be done by supplying the crypted password as salt :

crypt_md5(typed_pw, crypted_pw) == crypted_pw

See also

crypt()


Method rsaset_public_key

object Crypto.rsaset_public_key(bignum modulo, bignum pub)

FIXME

Document this function.

  CLASS Crypto.arcfour

Description

Implementation of the arcfour stream-crypto.


Method name

string name()

Description

Returns the string "ARCFOUR".


Method query_key_length

int query_key_length()

Description

Returns the minimum required encryption key length. Currently this is 1.


Method set_encrypt_key
Method set_decrypt_key

void set_encrypt_key(string key)
void set_decrypt_key(string key)

Description

Set the encryption/decryption key to key .


Method crypt

string crypt(string data)

Description

Returns the string data encrypted with the current encryption key.

See also

set_encrypt_key()

  CLASS Crypto.cast

Description

Implementation of the CAST block crypto.


Method name

string name()

Description

Returns the string "CAST".


Method query_block_size

int query_block_size()

Description

Return the encryption block size used by CAST.


Method query_key_length

int query_key_length()

Description

Return the encryption key length used by CAST.


Method set_encrypt_key

Crypto.cast set_encrypt_key(string key)

Description

Set the encryption key to key , and set the object to encryption mode.

Returns the current object.


Method set_decrypt_key

Crypto.cast set_decrypt_key(string key)

Description

Set the decryption key to key , and set the object to decryption mode.

Returns the current object.


Method crypt_block

string crypt_block(string data)

Description

Encrypt/decrypt the string data with the current key.

If data is longer than the block size, additional blocks will be encrypted the same way as the first one (ie ECB-mode).

Note

Will throw errors if

sizeof(data )
is not a multiple of the block size.

See also

set_encrypt_key() , set_decrypt_key()

  CLASS Crypto.cbc

Description

Implementation of the cipher block chaining mode (CBC).


Method create

void Crypto.cbc(object cipher)

Description

Initialize a cipher block chaining object with the cipher cipher .


Method query_block_size

int query_block_size()

Description

Return the block size of the contained object.


Method query_key_length

int query_key_length()

Description

Return the encryption key length of the contained object.


Method set_encrypt_key

object set_encrypt_key(string key)

Description

Set the encryption key of the contained object.


Method set_decrypt_key

object set_decrypt_key(string key)

Description

Set the decryption key of the contained object.


Method set_iv

object set_iv(string iv)

Description

Set the initialization vector to iv .


Method encrypt_block

string encrypt_block(string data)

Description

Encrypt the string data according to the cipher block chaining mode.


Method decrypt_block

string decrypt_block(string data)

Description

Decrypt the string data according to the cipher block chaining mode.


Method crypt_block

string crypt_block(string data)

Description

Encrypt/decrypt the string data according to the cipher block chaining mode.

  CLASS Crypto.crypto

Description

Buffer a block-crypto.


Method create

void Crypto.crypto(object cipher)
void Crypto.crypto(program prog, mixed ... args)

Description

Initialize a block-crypto buffer.


Method query_block_size

int query_block_size()

Description

Get the block size of the contained block-crypto.


Method query_key_length

int query_key_length()


Method set_encrypt_key

void set_encrypt_key(string key)

Description

Set the encryption key.

Note

As a side-effect any buffered data will be cleared.


Method set_decrypt_key

void set_decrypt_key(string key)

Description

Set the decryption key.

Note

As a side-effect any buffered data will be cleared.


Method crypt

string crypt(string data)

Description

Encrypt some data.

Adds data to be encrypted to the buffer. If there's enough data to en/decrypt a block, that will be done, and the result returned. Any uncrypted data will be left in the buffer.


Method pad

string pad()

Description

Pad and de/encrypt any data left in the buffer.

See also

unpad()


Method unpad

string unpad(string data)

Description

De/encrypt and unpad a block of data.

This performs the reverse operation of pad() .

See also

pad()

  CLASS Crypto.rijndael

Description

Implementation of the Rijndael (aka AES) block-crypto.

See also

Crypto.aes


Method name

string name()

Description

Returns the string "RIJNDAEL".


Method query_block_size

int query_block_size()

Description

Returns the Rijndael block size.


Method query_key_length

int query_key_length()

Description

Returns the key length used by Rijndael (currently 32).


Method set_encrypt_key

void set_encrypt_key(string key)

Description

Set the encryption key.


Method set_decrypt_key

void set_decrypt_key(string key)

Description

Set the decryption key.


Method encrypt

string encrypt(string data)

Description

De/encrypt data with Rijndael using the current key.

  CLASS Crypto.des

Description

Implementation of the Data Encryption Standard (DES).


Method name

string name()

Description

Return the string "DES".


Method query_block_size

int query_block_size()

Description

Return the block size used by DES.


Method query_key_length

int query_key_length()

Description

Return the key length used by DES.


Method set_encrypt_key

void set_encrypt_key(string key)

Description

Set the encryption key.


Method set_decrypt_key

void set_decrypt_key(string key)

Description

Set the decryption key.


Method crypt_block

string crypt_block(string data)

Description

En/decrypt data with DES using the current key.

  CLASS Crypto.idea

Description

Support for the IDEA block crypto.


Method name

string name()

Description

Return the string "IDEA".


Method query_block_size

int query_block_size()

Description

Return the block size for IDEA.


Method query_key_length

int query_key_length()

Description

Return the key length for IDEA.


Method set_encrypt_key

void set_encrypt_key(string key)

Description

Set the encryption key to key .


Method set_decrypt_key

void set_decrypt_key(string key)

Description

Set the decryption key to key .


Method crypt_block

string crypt_block(string data)

Description

De/encrypt data with IDEA.

  CLASS Crypto.invert

Description

Inversion crypto module.


Method name

string name()

Description

Returns the string "INVERT".


Method query_block_size

int query_block_size()

Description

Returns the block size for the invert crypto (currently 8).


Method query_key_length

int query_key_length()

Description

Returns the minimum key length for the invert crypto.

Since this crypto doesn't use a key, this will be 0.


Method set_key

void set_key(string key)

Description

Set the encryption key (currently a no op).


Method crypt_block

string crypt_block(string data)

Description

De/encrypt the string data with the invert crypto (ie invert the string).

  CLASS Crypto.md2

Description

Implementation of the MD2 message digest algorithm.


Method name

string name()

Description

Returns the string "MD2".


Method create

void Crypto.md2(Crypto.md2|void init)

Description

Initialize an MD2 digest.

If the argument init is specified, the state from it will be copied.


Method update

Crypto.md2 update(string data)

Description

Feed some data to the digest algorithm.


Method identifier

string identifier()

Description

Returns the ASN1 identifier for an MD2 digest.


Method digest

string digest()

Description

Return the digest.

Note

As a side effect the object will be reinitialized.

  CLASS Crypto.md4

Description

Implementation of the MD4 message digest algorithm.


Method name

string name()

Description

Return the string "MD4".


Method create

void Crypto.md4(Crypto.md4|void init)

Description

Initialize an MD4 digest.

If the argument init is specified, the state from it will be copied.


Method update

Crypto.md4 update(string data)

Description

Feed some data to the digest algorithm.


Method identifier

string identifier()

Description

Returns the ASN1 identifier for an MD4 digest.


Method digest

string digest()

Description

Return the digest.

Note

As a side effect the object will be reinitialized.

  CLASS Crypto.md5

Description

Implementation of the MD5 message digest algorithm.


Method name

string name()

Description

Return the string "MD5".


Method create

void Crypto.md5(Crypto.md5|void init)

Description

Initialize an MD5 digest.

If the argument init is specified, the state from it will be copied.


Method update

Crypto.md5 update(string data)

Description

Feed some data to the digest algorithm.


Method identifier

string identifier()

Description

Returns the ASN1 identifier for an MD5 digest.


Method digest

string digest()

Description

Return the digest.

Note

As a side effect the object will be reinitialized.

  CLASS Crypto.nt


Method CryptAcquireContext

CryptoContext CryptAcquireContext(string str1, string str2, int typ, int flags)

  CLASS Crypto.nt.CryptoContext


Method CryptGenRandom

string CryptGenRandom(int size, string|void init)

  CLASS Crypto.pipe

Description

Chains serveral block-cryptos.

This can be used to implement eg DES3.


Method create

void Crypto.pipe(program|object|array(program|mixed) ciphers)

Description

Initialize a block-crypto pipe.


Method name

string name()

Description

Returns the string "PIPE(" followed by a comma-separated list of the names of contained ciphers, and terminated with the string ")".


Method query_block_size

int query_block_size()

Description

Returns the joined block size.


Method query_key_length

array(int|array) query_key_length()

Description

Returns an array of the contained ciphers key lengths.


Method set_encrypt_key

void set_encrypt_key(array|string ... keys)

Description

Sets the encryption keys for the contained ciphers.


Method set_decrypt_key

void set_decrypt_key(array|string ... keys)

Description

Sets the decryption keys for the contained ciphers.


Method crypt_block

string crypt_block(string data)

Description

De/encrypts the string data with the contained ciphers in sequence.

  CLASS Crypto.sha


Method name

string name()

Description

Returns the string "SHA".


Method create

void Crypto.sha(Crypto.sha|void init)

Description

Initialize an SHA digest.

If the argument init is specified, the state from it will be copied.


Method update

Crypto.sha update(string data)

Description

Feed some data to the digest algorithm.


Method identifier

string identifier()

Description

Returns the ASN1 identifier for an SHA digest.


Method digest

string digest()

Description

Return the digest.

Note

As a side effect the object will be reinitialized.

  CLASS Crypto.des3

Description

Triple-DES

See also

pipe , des


Inherit pipe

inherit Crypto.pipe : pipe


Method query_key_size

int query_key_size()

FIXME

Document this function.


Method query_block_size

int query_block_size()

FIXME

Document this function.


Method set_encrypt_key

object set_encrypt_key(string key)

FIXME

Document this function.

Throws

An exception will be raised if key is weak


Method set_decrypt_key

object set_decrypt_key(string key)

FIXME

Document this function.

Throws

An exception will be raised if key is weak

  CLASS Crypto.aes

Description

Advanced Encryption Standard (AES), previously known as Crypto.rijndael .


Inherit rijndael

inherit Crypto.rijndael : rijndael


Method name

string name()

Description

Returns the string "AES".

  CLASS Crypto.des3_cbc

Description

Triple-DES CBC.

See also

cbc , des


Inherit cbc

inherit Crypto.cbc : cbc

  CLASS Crypto.des_cbc

Description

DES CBC.

See also

cbc , des


Inherit cbc

inherit Crypto.cbc : cbc

  CLASS Crypto.dsa

Description

The Digital Signature Algorithm (aka DSS, Digital Signature Standard).


Method set_public_key

object set_public_key(bignum p_, bignum q_, bignum g_, bignum y_)

FIXME

Document this function.


Method set_private_key

object set_private_key(bignum secret)

FIXME

Document this function.


Method use_random

object use_random(function r)

FIXME

Document this function.


Method hash2number

bignum hash2number(string digest)

FIXME

Document this function.


Method dsa_hash

bignum dsa_hash(string msg)

FIXME

Document this function.


Method random_number

bignum random_number(bignum n)

Description

Generate a random number k, 0<=k<n


Method random_exponent

bignum random_exponent()

FIXME

Document this function.


Method raw_sign

array(bignum) raw_sign(bignum h)

FIXME

Document this function.


Method raw_verify

int raw_verify(bignum h, bignum r, bignum s)

FIXME

Document this function.


Method sign_rsaref

string sign_rsaref(string msg)

FIXME

Document this function.


Method verify_rsaref

int verify_rsaref(string msg, string s)

FIXME

Document this function.


Method sign_ssl

string sign_ssl(string msg)

FIXME

Document this function.


Method verify_ssl

int verify_ssl(string msg, string s)

FIXME

Document this function.


Method set_public_test_key

object set_public_test_key()

FIXME

Document this function.


Method set_private_test_key

object set_private_test_key()

FIXME

Document this function.


Method nist_hash

string nist_hash(bignum x)

Description

The (slow) NIST method of generating DSA primes. Algorithm 4.56 of Handbook of Applied Cryptography.


Method nist_primes

array(bignum) nist_primes(int l)

Description

Returns ({ p, q })

FIXME

Document this function.


Method find_generator

bignum find_generator(bignum p, bignum q)

FIXME

Document this function.


Method generate_parameters

object generate_parameters(int bits)

FIXME

Document this function.


Method generate_key

object generate_key()

FIXME

Document this function.


Method public_key_equal

int public_key_equal(object dsa)

FIXME

Document this function.

  CLASS Crypto.hmac

Description

HMAC, defined by RFC-2104


Method create

void Crypto.hmac(function h, int|void b)

FIXME

Document this function.


Method raw_hash

string raw_hash(string s)

FIXME

Document this function.


Method pkcs_digest

string pkcs_digest(string s)

FIXME

Document this function.

  CLASS Crypto.hmac.`()

FIXME

Document this function.


Method create

void Crypto.hmac.`()(string passwd)

FIXME

Document this function.


Method `()

string `()(string text)

FIXME

Document this function.


Method digest_info

string digest_info(string text)

FIXME

Document this function.

  CLASS Crypto.idea_cbc

Description

IDEA CBC.

See also

cbc , idea


Inherit cbc

inherit Crypto.cbc : cbc

  CLASS Crypto.rsa


Method raw_sign

bignum raw_sign(string digest)

FIXME

Document this function.


Method get_n

bignum get_n()

FIXME

Document this function.


Method get_e

bignum get_e()

FIXME

Document this function.


Method get_d

bignum get_d()

FIXME

Document this function.


Method get_p

bignum get_p()

FIXME

Document this function.


Method get_q

bignum get_q()

FIXME

Document this function.


Method cooked_get_p

string cooked_get_p()

FIXME

Document this function.


Method cooked_get_q

string cooked_get_q()

FIXME

Document this function.


Method set_private_key

object set_private_key(bignum priv, array(bignum)|void extra)

FIXME

Document this function.


Method sign

object sign(string message, program h)

FIXME

Document this function.


Method verify

int verify(string msg, program h, object sign)

FIXME

Document this function.


Method sha_sign

string sha_sign(string message, mixed|void r)

FIXME

Document this function.


Method sha_verify

int sha_verify(string message, string signature)

FIXME

Document this function.


Method md5_sign

string md5_sign(string message, mixed|void r)

FIXME

Document this function.


Method md5_verify

int md5_verify(string message, string signature)

FIXME

Document this function.


Method get_prime

bignum get_prime(int bits, function r)

FIXME

Document this function.


Method generate_key

object generate_key(int bits, function|void r)

FIXME

Document this function.


Method set_encrypt_key

object set_encrypt_key(array(bignum) key)

FIXME

Document this function.


Method set_decrypt_key

object set_decrypt_key(array(bignum) key)

FIXME

Document this function.


Method crypt_block

string crypt_block(string s)

FIXME

Document this function.


Method query_blocksize

int query_blocksize()

FIXME

Document this function.


Method rsa_pad

bignum rsa_pad(string message, int type, mixed|void random)

FIXME

Document this function.


Method rsa_unpad

string rsa_unpad(bignum block, int type)

FIXME

Document this function.


Method cooked_sign

string cooked_sign(string digest)

FIXME

Document this function.


Method raw_verify

int raw_verify(string digest, bignum s)

FIXME

Document this function.


Method encrypt

string encrypt(string s, mixed|void r)

FIXME

Document this function.


Method decrypt

string decrypt(string s)

FIXME

Document this function.


Method rsa_size

int rsa_size()

FIXME

Document this function.


Method public_key_equal

int public_key_equal(object rsa_wrapper)

FIXME

Document this function.

  Module Crypto.randomness

Description

Assorted stronger or weaker randomnumber generators. These devices try to collect entropy from the environment. They differ in behaviour when they run low on entropy, /dev/random will block if it can't provide enough random bits, while /dev/urandom will degenerate into a reasonably strong pseudo random generator


Method reasonably_random

object Crypto.randomness.reasonably_random()


Method really_random

object Crypto.randomness.really_random(int|void may_block)

  CLASS Crypto.randomness.pike_random

Description

A pseudo random generator based on the ordinary random() function.


Method read

string read(int len)

Description

Returns a string of length len with pseudo random values.

  CLASS Crypto.randomness.arcfour_random

Description

A pseudo random generator based on the arcfour crypto.


Inherit arcfour

inherit Crypto.arcfour : arcfour


Method create

void Crypto.randomness.arcfour_random(string secret)

Description

Initialize and seed the arcfour random generator.


Method read

string read(int len)

Description

Return a string of the next len random characters from the arcfour random generator.

  Module _Ffmpeg


constant _Ffmpeg.CODEC_ID_NONE
constant _Ffmpeg.CODEC_ID_AC3
constant _Ffmpeg.CODEC_ID_ADPCM_IMA_QT
constant _Ffmpeg.CODEC_ID_ADPCM_IMA_WAV
constant _Ffmpeg.CODEC_ID_ADPCM_MS
constant _Ffmpeg.CODEC_ID_H263
constant _Ffmpeg.CODEC_ID_H263I
constant _Ffmpeg.CODEC_ID_H263P
constant _Ffmpeg.CODEC_ID_MJPEG
constant _Ffmpeg.CODEC_ID_MPEG1VIDEO
constant _Ffmpeg.CODEC_ID_MPEG4
constant _Ffmpeg.CODEC_ID_MP2
constant _Ffmpeg.CODEC_ID_MP3LAME
constant _Ffmpeg.CODEC_ID_MSMPEG4V1
constant _Ffmpeg.CODEC_ID_MSMPEG4V2
constant _Ffmpeg.CODEC_ID_MSMPEG4V3
constant _Ffmpeg.CODEC_ID_PCM_ALAW
constant _Ffmpeg.CODEC_ID_PCM_MULAW
constant _Ffmpeg.CODEC_ID_PCM_S16BE
constant _Ffmpeg.CODEC_ID_PCM_S16LE
constant _Ffmpeg.CODEC_ID_PCM_S8
constant _Ffmpeg.CODEC_ID_PCM_U16BE
constant _Ffmpeg.CODEC_ID_PCM_U16LE
constant _Ffmpeg.CODEC_ID_PCM_U8
constant _Ffmpeg.CODEC_ID_RAWVIDEO
constant _Ffmpeg.CODEC_ID_RV10
constant _Ffmpeg.CODEC_ID_SVQ1
constant _Ffmpeg.CODEC_ID_VORBIS
constant _Ffmpeg.CODEC_ID_WMV1
constant _Ffmpeg.CODEC_ID_WMV2

Description

Various audio and video codecs.

Note

The list of supported codecs depends on Ffmpeg library.


constant _Ffmpeg.CODEC_TYPE_AUDIO
constant _Ffmpeg.CODEC_TYPE_VIDEO

Description

Type of codec.

  CLASS _Ffmpeg.ffmpeg

Description

Implements support of all codecs from a nice project Ffmpeg. You can find more info about it at http://ffmpeg.sf.net/.


Method create

void _Ffmpeg.ffmpeg(int codec_name, int encoder)

Description

Create decoder or encoder object.

Parameter codec_name

Internal number of codec, eg. CODEC_ID_MP2 .

Parameter encoder

If true, encoder object will be created, decoder object otherwise.


Method get_codec_info

mapping|int get_codec_info()

Description

Returns mapping with info of used codec.

See also

list_codecs()


Method set_codec_param

int set_codec_param(string name, mixed value)

Description

Sets one codec parameter

Parameter name

The name of parameter. One of "sample_rate", "bit_rate", "channels".

Returns

Returns 1 on success, 0 otherwise (parameter not known).

See also

get_codec_params()


Method get_codec_status

mapping|int get_codec_status()

Description

Returns a mapping with the actual codec parameters.

See also

set_codec_param()


Method decode

mapping|int decode(string data)

Description

Returns a mapping with the new decoded frame and lenght of data which was used for decoding.


Method decode

int decode(string data, function shuffler)

Description

Decode all data buffer and pass result to shuffler . Returns 1 on success, 0 otherwise.

Note

Shuffler variant isn't implemented, yet.

Note

Usable only in decoder.

See also

create()


Method list_codecs

array(mapping) list_codecs()

Description

Gets all supported codecs.

Returns

Array of mapping with codec features.

  Module spider


Method discdate

string spider.discdate(int time)


Method parse_accessed_database

array(mapping(string:int)|int) spider.parse_accessed_database(string database)


Method parse_html

string spider.parse_html(string html, mapping(string:function(string:string|array)) tag_callbacks, mapping(string:function(string:string|array)) container_callbacks, mixed ... extras)


Method parse_html_lines

string spider.parse_html_lines(string html, mapping(string:function(string:string|array)) tag_callbacks, mapping(string:function(string:string|array)) container_callbacks, mixed ... extras)


Method set_end_quote

void spider.set_end_quote(int quote)


Method set_start_quote

void spider.set_start_quote(int quote)


Method get_all_active_fds

array(int) spider.get_all_active_fds()


Method fd_info

string spider.fd_info(int fd)


Method _low_program_name

string spider._low_program_name(program prog)


Method _dump_obj_table

array(array(string|int)) spider._dump_obj_table()


Method stardate

string spider.stardate(int time, int precision)


Method parse_xml

array spider.parse_xml(string xml, function cb)

  Module System

Description

This module embodies common operating system calls, making them available to the Pike programmer.


Method RegGetValue

string|int|array(string) System.RegGetValue(int hkey, string key, string index)

Description

Get a single value from the register.

Parameter hkey

One of the following:

HKEY_CLASSES_ROOT
HKEY_LOCAL_MACHINE
HKEY_CURRENT_USER
HKEY_USERS

Parameter key

Registry key.

Parameter index

Value name.

Returns

Returns the value stored at the specified location in the register if any. Throws errors on failure.

Note

This function is only available on Win32 systems.

See also

RegGetValues() , RegGetKeyNames()


Method RegGetKeyNames

array(string) System.RegGetKeyNames(int hkey, string key)

Description

Get a list of value key names from the register.

Parameter hkey

One of the following:

HKEY_CLASSES_ROOT
HKEY_LOCAL_MACHINE
HKEY_CURRENT_USER
HKEY_USERS

Parameter key

Registry key.

Returns

Returns an array of value keys stored at the specified location iof any. Throws errors on failure.

Note

This function is only available on Win32 systems.

See also

RegGetValue() , RegGetValues()


Method RegGetValues

mapping(string:string|int|array(string)) System.RegGetValues(int hkey, string key)

Description

Get multiple values from the register.

Parameter hkey

One of the following:

HKEY_CLASSES_ROOT
HKEY_LOCAL_MACHINE
HKEY_CURRENT_USER
HKEY_USERS

Parameter key

Registry key.

Returns

Returns a mapping with all the values stored at the specified location in the register if any. Throws errors on failure.

Note

This function is only available on Win32 systems.

See also

RegGetValue() , RegGetKeyNames()


Method LogonUser

object System.LogonUser(string username, string|int(0..0) domain, string password, int|void logon_type, int|void logon_provider)

Description

Logon a user.

Parameter username

User name of the user to login.

Parameter domain

Domain to login on, or zero if local logon.

Parameter password

Password to login with.

Parameter logon_type

One of the following values:

LOGON32_LOGON_BATCH 
LOGON32_LOGON_INTERACTIVE 
LOGON32_LOGON_SERVICE 
LOGON32_LOGON_NETWORK

This is the default.


Parameter logon_provider

One of the following values:

LOGON32_PROVIDER_DEFAULT

This is the default.


Returns

Returns a login token object on success, and zero on failure.

Note

This function is only available on some Win32 systems.


Method NetUserGetInfo

string|array(string|int) System.NetUserGetInfo(string username, string|int(0..0) server, int|void level)

Description

Get information about a network user.

Parameter username

User name of the user to get information about.

Parameter server

Server the user exists on.

Parameter level

Information level. One of:

0
1
2
3
10
11
20

Returns

Returns an array on success. Throws errors on failure.

FIXME

Document the return value.

Note

This function is only available on some Win32 systems.

See also

NetUserEnum() , NetGroupEnum() NetLocalGroupEnum() , NetUserGetGroups() , NetUserGetLocalGroups() , NetGroupGetUsers() , NetLocalGroupGetMembers() , NetGetDCName() , NetGetAnyDCName()


Method NetUserEnum

array(string|array(string|int)) System.NetUserEnum(string|int(0..0)|void server, int|void level, int|void filter)

Description

Get information about network users.

Parameter server

Server the users exist on.

Parameter level

Information level. One of:

0
1
2
3
10
11
20

Returns

Returns an array on success. Throws errors on failure.

FIXME

Document the return value.

Note

This function is only available on some Win32 systems.

See also

NetUserGetInfo() , NetGroupEnum() NetLocalGroupEnum() , NetUserGetGroups() , NetUserGetLocalGroups() , NetGroupGetUsers() , NetLocalGroupGetMembers() , NetGetDCName() , NetGetAnyDCName()


Method NetGroupEnum

array(string|array(string|int)) System.NetGroupEnum(string|int(0..0)|void server, int|void level)

Description

Get information about network groups.

Parameter server

Server the groups exist on.

Parameter level

Information level. One of:

0
1
2

Returns

Returns an array on success. Throws errors on failure.

FIXME

Document the return value.

Note

This function is only available on some Win32 systems.

See also

NetUserGetInfo() , NetUserEnum() , NetLocalGroupEnum() , NetUserGetGroups() , NetUserGetLocalGroups() , NetGroupGetUsers() , NetLocalGroupGetMembers() , NetGetDCName() , NetGetAnyDCName()


Method NetLocalGroupEnum

array(array(string|int)) System.NetLocalGroupEnum(string|int(0..0)|void server, int|void level)

Description

Get information about local network groups.

Parameter server

Server the groups exist on.

Parameter level

Information level. One of:

0
1

Returns

Returns an array on success. Throws errors on failure.

FIXME

Document the return value.

Note

This function is only available on some Win32 systems.

See also

NetUserGetInfo() , NetUserEnum() , NetGroupEnum() , NetUserGetGroups() , NetUserGetLocalGroups() , NetGroupGetUsers() , NetLocalGroupGetMembers() , NetGetDCName() , NetGetAnyDCName()


Method NetUserGetGroups

array(array(string|int)) System.NetUserGetGroups(string|int(0..0) server, string user, int|void level)

Description

Get information about group membership for a network user.

Parameter server

Server the groups exist on.

Parameter user

User to retrieve groups for.

Parameter level

Information level. One of:

0
1

Returns

Returns an array on success. Throws errors on failure.

FIXME

Document the return value.

Note

This function is only available on some Win32 systems.

See also

NetUserGetInfo() , NetUserEnum() , NetGroupEnum() , NetLocalGroupEnum() , NetUserGetLocalGroups() , NetGroupGetUsers() , NetLocalGroupGetMembers() , NetGetDCName() , NetGetAnyDCName()


Method NetUserGetLocalGroups

array(string) System.NetUserGetLocalGroups(string|int(0..0) server, string user, int|void level, int|void flags)

Description

Get information about group membership for a local network user.

Parameter server

Server the groups exist on.

Parameter user

User to retrieve groups for.

Parameter level

Information level. One of:

0

Parameter flags

Zero, of one of the following:

LG_INCLUDE_INDIRECT

Returns

Returns an array on success. Throws errors on failure.

FIXME

Document the return value.

Note

This function is only available on some Win32 systems.

See also

NetUserGetInfo() , NetUserEnum() , NetGroupEnum() , NetLocalGroupEnum() , NetUserGetGroups() , NetGroupGetUsers() , NetLocalGroupGetMembers() , NetGetDCName() , NetGetAnyDCName()


Method NetGroupGetUsers

array(string|array(int|string)) System.NetGroupGetUsers(string|int(0..0) server, string group, int|void level)

Description

Get information about group membership for a network group.

Parameter server

Server the groups exist on.

Parameter group

Group to retrieve members for.

Parameter level

Information level. One of:

0
1

Returns

Returns an array on success. Throws errors on failure.

FIXME

Document the return value.

Note

This function is only available on some Win32 systems.

See also

NetUserGetInfo() , NetUserEnum() , NetGroupEnum() , NetLocalGroupEnum() , NetUserGetGroups() , NetUserGetLocalGroups() , NetLocalGroupGetMembers() , NetGetDCName() , NetGetAnyDCName()


Method NetLocalGroupGetMembers

array(string|array(int|string)) System.NetLocalGroupGetMembers(string|int(0..0) server, string group, int|void level)

Description

Get information about group membership for a network group.

Parameter server

Server the groups exist on.

Parameter group

Group to retrieve members for.

Parameter level

Information level. One of:

0
1
2
3

Returns

Returns an array on success. Throws errors on failure.

FIXME

Document the return value.

Note

This function is only available on some Win32 systems.

See also

NetUserGetInfo() , NetUserEnum() , NetGroupEnum() , NetLocalGroupEnum() , NetUserGetGroups() , NetUserGetLocalGroups() , NetGroupGetUsers() , NetGetDCName() , NetGetAnyDCName()


Method NetGetDCName

string System.NetGetDCName(string|int(0..0) server, string domain)

Description

Get name of the domain controller from a server.

Parameter server

Server the domain exists on.

Parameter domain

Domain to get the domain controller for.

Returns

Returns the name of the domain controller on success. Throws errors on failure.

Note

This function is only available on some Win32 systems.

See also

NetUserGetInfo() , NetUserEnum() , NetGroupEnum() , NetLocalGroupEnum() , NetUserGetGroups() , NetUserGetLocalGroups() , NetGroupGetUsers() , NetLocalGroupGetMembers() , NetGetAnyDCName()


Method NetGetAnyDCName

string System.NetGetAnyDCName(string|int(0..0) server, string domain)

Description

Get name of a domain controller from a server.

Parameter server

Server the domain exists on.

Parameter domain

Domain to get a domain controller for.

Returns

Returns the name of a domain controller on success. Throws errors on failure.

Note

This function is only available on some Win32 systems.

See also

NetUserGetInfo() , NetUserEnum() , NetGroupEnum() , NetLocalGroupEnum() , NetUserGetGroups() , NetUserGetLocalGroups() , NetGroupGetUsers() , NetLocalGroupGetMembers() , NetGetDCName()


Method NetSessionEnum

array(int|string) System.NetSessionEnum(string|int(0..0) server, string|int(0..0) client, string|int(0..0) user, int level)

Description

Get session information.

Parameter level

One of

0
1
2
10
502

Note

This function is only available on some Win32 systems.


Method NetWkstaUserEnum

array(mixed) System.NetWkstaUserEnum(string|int(0..0) server, int level)

Parameter level

One of

0
1

Note

This function is only available on some Win32 systems.


Method normalize_path

string System.normalize_path(string path)

Description

Normalize an NT filesystem path.

The following transformations are currently done:

  • Trailing slashes are removed.

  • Extraneous empty extensions are removed.

  • Short filenames are expanded to their corresponding long variants.

  • Forward slashes ('/') are converted to backward slashes ('\').

  • Current- and parent-directory paths are removed ("." and "..").

  • Relative paths are expanded to absolute paths.

  • Case-information is restored.

Returns

A normalized absolute path without trailing slashes.

Throws errors on failure, e.g. if the file or directory doesn't exist.

Note

File fork information is currently not supported (invalid data).

See also

combine_path() , combine_path_nt()


Method GetFileAttributes

int System.GetFileAttributes(string filename)

Description

Get the file attributes for the specified file.

Note

This function is only available on Win32 systems.

See also

SetFileAttributes()


Method SetFileAttributes

int System.SetFileAttributes(string filename)

Description

Set the file attributes for the specified file.

Note

This function is only available on Win32 systems.

See also

GetFileAttributes()


Method LookupAccountName

array(mixed) System.LookupAccountName(string|int(0..0) sys, string account)

Note

This function is only available on some Win32 systems.


Method SetNamedSecurityInfo

array(mixed) System.SetNamedSecurityInfo(string name, mapping(string:mixed) options)

Note

This function is only available on some Win32 systems.

See also

GetNamedSecurityInfo()


Method GetNamedSecurityInfo

mapping(mixed:mixed) System.GetNamedSecurityInfo(string name, int|void type, int|void flags)

Note

This function is only available on some Win32 systems.

See also

SetNamedSecurityInfo()


Method openlog

void System.openlog(string ident, int options, facility)

Description

Initializes the connection to syslogd.

Parameter ident.

The ident argument specifies an identifier to tag all logentries with.

Parameter options

A bitfield specifying the behaviour of the message logging. Valid options are:

LOG_PID

Log the process ID with each message.

LOG_CONS

Write messages to the console if they can't be sent to syslogd.

LOG_NDELAY

Open the connection to syslogd now and not later.

LOG_NOWAIT

Do not wait for subprocesses talking to syslogd.


Parameter facility

Specifies what subsystem you want to log as. Valid facilities are:

LOG_AUTH

Authorization subsystem

LOG_AUTHPRIV 
LOG_CRON

Crontab subsystem

LOG_DAEMON

System daemons

LOG_KERN

Kernel subsystem (NOT USABLE)

LOG_LOCAL

For local use

LOG_LOCAL1
LOG_LOCAL2
LOG_LOCAL3
LOG_LOCAL4
LOG_LOCAL5
LOG_LOCAL6
LOG_LOCAL7
LOG_LPR

Line printer spooling system

LOG_MAIL

Mail subsystem

LOG_NEWS

Network news subsystem

LOG_SYSLOG 
LOG_USER 
LOG_UUCP

UUCP subsystem


Note

Only available on systems with syslog(3).

Bugs

LOG_NOWAIT should probably always be specified.

See also

syslog , closelog


Method syslog

void System.syslog(int a, string b)

FIXME

Document this function.


Method closelog

void System.closelog()

FIXME

Document this function.


Method hardlink

void System.hardlink(string from, string to)

Description

Create a hardlink named to from the file from .

Note

This function is not available on all platforms.

See also

symlink() , mv() , rm()


Method symlink

void System.symlink(string from, string to)

Description

Create a symbolic link named to that points to from .

Note

This function is not available on all platforms.

See also

hardlink() , readlink() , mv() , rm()


Method readlink

string System.readlink(string path)

Description

Returns what the symbolic link path points to.

Note

This function is not available on all platforms.

See also

symlink()


Method resolvepath

string System.resolvepath(string path)

Description

Resolve all symbolic links of a pathname.

Note

This function is not available on all platforms.

See also

readlink() , symlink()


Method umask

int System.umask(void|int mask)

Description

Set the current umask to mask .

If mask is not specified the current umask will not be changed.

Returns

Returns the old umask setting.


Method chmod

void System.chmod(string path, int mode)

Description

Sets the protection mode of the specified path.

Note

Throws errors on failure.

See also

Stdio.File->open() , errno()


Method chown

void System.chown(string path, int uid, int gid)

Description

Sets the owner and group of the specified path.

Note

Throws errors on failure.

This function is not available on all platforms.


Method utime

void System.utime(string path, int atime, int mtime)

Description

Set the last access time and last modification time for the path path to atime and mtime repectively.

Note

Throws errors on failure.

This function is not available on all platforms.


Method initgroups

void System.initgroups(string name, int base_gid)

Description

Initializes the supplemental group access list according to the system group database. base_gid is also added to the group access list.

Note

Throws errors on failure.

This function is not available on all platforms.

See also

setuid() , getuid() , setgid() , getgid() , seteuid() , geteuid() , setegid() , getegid() , getgroups() , setgroups()


Method cleargroups

void System.cleargroups()

Description

Clear the supplemental group access list.

Note

Throws errors on failure.

This function is not available on all platforms.

See also

setgroups() , initgroups() , getgroups()


Method setgroups

void System.setgroups(array(int) gids)

Description

Set the supplemental group access list for this process.

Note

Throws errors on failure.

This function is not available on all platforms.

See also

initgroups() , cleargroups() , getgroups() , getgid() , getgid() , getegid() , setegid()


Method getgroups

array(int) System.getgroups()

Description

Get the current supplemental group access list for this process.

Note

Throws errors on failure.

This function is not available on all platforms.

See also

setgroups() , cleargroups() , initgroups() , getgid() , getgid() , getegid() , setegid()


Method innetgr

int System.innetgr(string netgroup, string|void machine, string|void user, string|void domain)

FIXME

Document this function.


Method setuid

void System.setuid(int uid)

Description

Sets the real user ID, effective user ID and saved user ID to uid .

See also

getuid() , setgid() , getgid() , seteuid() , geteuid() , setegid() , getegid()


Method setgid

void System.setgid(int gid)

Description

Sets the real group ID, effective group ID and saved group ID to gid .

See also

getuid() , setuid() , getgid() , seteuid() , geteuid() , setegid() , getegid()


Method seteuid

int System.seteuid(int euid)

Description

Set the effective user ID to euid .


Method setegid

int System.setegid(int egid)

Description

Set the effective group ID to egid .


Method getpgrp

int System.getpgrp(int|void pid)

Description

Get the process group id for the process pid . With no argguments or with 'pid' equal to zero, returns the process group ID of this process.

Note

Not all platforms support getting the process group for other processes.

Not supported on all platforms.

See also

getpid , getppid


Method setpgrp

int System.setpgrp()

Description

Make this process a process group leader.

Note

Not supported on all platforms.


Method getsid

int System.getsid(int|void pid)

Description

Get the process session ID for the given process. If pid is not specified, the session ID for the current process will be returned.

See also

getpid , getpgrp , setsid


Method setsid

int System.setsid()

Description

Set a new process session ID for the current process, and return it.

See also

getpid , setpgrp , getsid


Method dumpable

int(0..1) System.dumpable(int(0..1)|void val)

Description

Get and/or set whether this process should be able to dump core.

Parameter val

Optional argument to set the core dumping state.

0

Disable core dumping for this process.

1

Enable core dumping for this process.


Returns

Returns 1 if this process currently is capable of dumping core, and 0 (zero) if not.

Note

This function is currently only available on some versions of Linux.


Method setresuid

int System.setresuid(int ruid, int euid, int suid)

FIXME

Document this function.


Method setresgid

int System.setresgid(int rgid, int egid, int sgid)

FIXME

Document this function.


Method getuid

int System.getuid()

Description

Get the real user ID.

See also

setuid , setgid , getgid , seteuid , geteuid , setegid , getegid


Method getgid

int System.getgid()

Description

Get the real group ID.

See also

setuid , getuid , setgid , seteuid , geteuid , getegid , setegid


Method geteuid

int System.geteuid()

Description

Get the effective user ID.

See also

setuid , getuid , setgid , getgid , seteuid , getegid , setegid


Method getegid

int System.getegid()

Description

Get the effective group ID.

See also

setuid , getuid , setgid , getgid , seteuid , geteuid , setegid


Method getpid

int System.getpid()

Description

Returns the process ID of this process.

See also

getppid , getpgrp


Method getppid

int System.getppid()

Description

Returns the process ID of the parent process.

See also

getpid , getpgrp


Method chroot

int System.chroot(string newroot)
int System.chroot(Stdio.File newroot)

Description

Changes the root directory for this process to the indicated directory.

Note

Since this function modifies the directory structure as seen from Pike, you have to modify the environment variables PIKE_MODULE_PATH and PIKE_INCLUDE_PATH to compensate for the new root-directory.

This function only exists on systems that have the chroot(2) system call.

The second variant only works on systems that also have the fchroot(2) system call.


Method uname

mapping(string:string) System.uname()

Description

Get operating system information.

Returns

The resulting mapping contains the following fields:

"sysname" : string

Operating system name.

"nodename" : string

Hostname.

"release" : string

Operating system release.

"version" : string

Operating system version.

"machine" : string

Hardware architecture.

"architecture" : string

Basic instruction set architecture.

"isalist" : string

List of upported instruction set architectures. Usually space-separated.

"platform" : string

Specific model of hardware.

"hw provider" : string

Manufacturer of the hardware.

"hw serial" : string

Serial number of the hardware.

"srpc domain" : string

Secure RPC domain.


Note

This function only exists on systems that have the uname(2) or sysinfo(2) system calls.

Only the first five elements are always available.


Method gethostname

string System.gethostname()

Description

Returns a string with the name of the host.

Note

This function only exists on systems that have the gethostname(2) or uname(2) system calls.


Method gethostbyaddr

array(string|array(string)) System.gethostbyaddr(string addr)

Description

Returns an array with information about the specified IP address.

Returns

The returned array contains the same information as that returned by gethostbyname() .

Note

This function only exists on systems that have the gethostbyaddr(2) or similar system call.

See also

gethostbyname()


Method gethostbyname

array(string|array(string)) System.gethostbyname(string hostname)

Description

Returns an array with information about the specified host.

Returns

The returned array contains the following:

Array
string hostname

Name of the host.

array(string) ips

Array of IP numbers for the host.

array(string) aliases

Array of alternative names for the host.


Note

This function only exists on systems that have the gethostbyname(2) or similar system call.

See also

gethostbyaddr()


Method sleep

int System.sleep(int seconds)

Description

Call the system sleep() function.

This is not to be confused with the global function predef::sleep() that does more elaborate things and can sleep with better precision (although dependant on a normal functioning system clock).

Note

The system's sleep function often utilizes the alarm(2) call and might not be perfectly thread safe in combination with simultaneous sleep()'s or alarm()'s. It might also be interrupted by other signals.

If you don't need it to be independant of the system clock, use predef::sleep() instead.

May not be present; only exists if the function exists in the current system.

See also

predef::sleep() usleep() nanosleep()


Method usleep

void System.usleep(int usec)

Description

Call the system usleep() function.

This is not to be confused with the global function predef::sleep() that does more elaborate things and can sleep with better precision (although dependant on a normal functioning system clock).

Note

The system's usleep function often utilizes the alarm(2) call and might not be perfectly thread safe in combination with simultaneous sleep()'s or alarm()'s. It might also be interrupted by other signals.

If you don't need it to be independant of the system clock, use predef::sleep() instead.

May not be present; only exists if the function exists in the current system.

See also

predef::sleep() sleep() nanosleep()


Method nanosleep

float System.nanosleep(int|float seconds)

Description

Call the system nanosleep() function.

This is not to be confused with the global function predef::sleep() that does more elaborate things and can sleep with better precision (although dependant on a normal functioning system clock).

Returns the remaining time to sleep (as the system function does).

See also

predef::sleep() sleep() usleep()

Note

May not be present; only exists if the function exists in the current system.


Method getrlimit

array(int) System.getrlimit(string resource)

FIXME

Document this function.


Method getrlimits

mapping(string:array(int)) System.getrlimits()

FIXME

Document this function.


Method setrlimit

int(0..1) System.setrlimit(string resource, int cur, int max)

FIXME

Document this function.


Method setitimer

float System.setitimer(int|float arg)

FIXME

Document this function.


Method getitimer

array(float) System.getitimer()

FIXME

Document this function.


Method get_netinfo_property

array(string) System.get_netinfo_property(string domain, string path, string property)

Description

Queries a NetInfo server for property values at the given path.

Parameter domain

NetInfo domain. Use "." for the local domain.

Parameter path

NetInfo path for the property.

Parameter property

Name of the property to return.

Returns

An array holding all property values. If the path or property cannot be not found 0 is returned instead. If the NetInfo domain is not found or cannot be queried an exception is thrown.

Example

system.get_netinfo_property(".", "/locations/resolver", "domain"); ({ "idonex.se" })

Note

Only available on operating systems which have NetInfo libraries installed.


Method rdtsc

int System.rdtsc()

Description

Executes the rdtsc (clock pulse counter) instruction and returns the result.


Method gettimeoday

array(int) System.gettimeoday()

Description

Calls gettimeofday(); the result is an array of seconds, microseconds, and possible tz_minuteswes, tz_dstttime as given by the gettimeofday(2) system call (read the man page).

  CLASS System.Memory

Description

A popular demand is a class representing a raw piece of memory or a mmap'ed file. This is usually not the most effective way of solving a problem, but it might help in rare situations.

Using mmap can lead to segmentation faults in some cases. Beware, and read about mmap before you try anything. Don't blame Pike if you shoot your foot off.


Method create

void System.Memory()
void System.Memory(string|Stdio.File filename_to_mmap)
void System.Memory(int shmkey, int shmsize, int shmflg)
void System.Memory(int bytes_to_allocate)

Description

Will call mmap() or allocate() depending on argument, either mmap'ing a file (in shared mode, writeable if possible) or allocating a chunk of memory.


Method mmap
Method mmap_private

int mmap(string|Stdio.File file)
int mmap(string|Stdio.File file, int offset, int size)
int mmap_private(string|Stdio.File file)
int mmap_private(string|Stdio.File file, int offset, int size)

Description

mmap a file. This will always try to mmap the file in PROT_READ|PROT_WRITE, readable and writable, but if it fails it will try once more in PROT_READ only.


Method allocate

void allocate(int bytes)
void allocate(int bytes, int(0..255) fill)


Method free

void free()

Description

Free the allocated or <tt>mmap</tt>ed memory.


Method _sizeof

int _sizeof()

Description

returns the size of the memory (bytes). note: throws if not allocated


Method valid

int(0..1) valid()

Description

returns 1 if the memory is valid, 0 if not allocated


Method writeable

int(0..1) writeable()

Description

returns 1 if the memory is writeable, 0 if not


Method cast

string|array cast(string to)

Description

Cast to string or array.

Note

Throws if not allocated.


Method pread
Method pread16
Method pread32
Method pread16i
Method pread32i
Method pread16n
Method pread32n

string pread(int(0..) pos, int(0..) len)
string pread16(int(0..) pos, int(0..) len)
string pread32(int(0..) pos, int(0..) len)
string pread16i(int(0..) pos, int(0..) len)
string pread32i(int(0..) pos, int(0..) len)
string pread16n(int(0..) pos, int(0..) len)
string pread32n(int(0..) pos, int(0..) len)

Description

Read a string from the memory. The 16 and 32 variants reads widestrings, 16 or 32 bits (2 or 4 bytes) wide, the i variants in intel byteorder, the normal in network byteorder, and the n variants in native byteorder.

len is the number of characters, wide or not. pos is the byte position (!).


Method pwrite
Method pwrite16
Method pwrite32
Method pwrite16i
Method pwrite32i

int pwrite(int(0..) pos, string data)
int pwrite16(int(0..) pos, string data)
int pwrite32(int(0..) pos, string data)
int pwrite16i(int(0..) pos, string data)
int pwrite32i(int(0..) pos, string data)

Description

Write a string to the memory (and to the file, if it's mmap()ed). The 16 and 32 variants writes widestrings, 16 or 32 bits (2 or 4 bytes) wide, the 'i' variants in intel byteorder, the other in network byteorder.

returns the number of bytes (not characters) written


Method `[]

int `[](int pos)
string `[](int pos1, int pos2)


Method `[]=

int `[]=(int pos, int char)
string `[]=(int pos1, int pos2, string str)

  CLASS System.Time

Description

The current time as a structure containing a sec and a usec member.


int sec
int usec

Description

The number of seconds and microseconds since the epoch and the last whole second, respectively. (See also predef::time() )

Please note that these variables will continually update when they are requested, there is no need to create new Time() objects.


Variable usec_full

int usec_full

Description

The number of microseconds since the epoch. Please note that pike has to have been compiled with bignum support for this variable to contain sensible values.


Method create

void System.Time(int fast)

Description

If fast is true, do not request a new time from the system, instead use the global current time variable.

This will only work in callbacks, but can save significant amounts of CPU.

  CLASS System.Timer


Method peek

float peek()

Description

Return the time in seconds since the last time get was called.


Method get

float get()

Description

Return the time in seconds since the last time get was called. The first time this method is called the time since the object was created is returned instead.


Method create

void System.Timer(int|void fast)

Description

Create a new timer object. The timer keeps track of relative time with sub-second precision.

If fast is specified, the timer will not do system calls to get the current time but instead use the one maintained by pike. This will result in faster but somewhat more inexact timekeeping. Also, if your program never utilizes the pike event loop the pike maintained current time never change.

  Module Pike


constant Pike.WEAK_INDICES = __builtin.PIKE_WEAK_INDICES
constant Pike.WEAK_VALUES = __builtin.PIKE_WEAK_VALUES
constant Pike.WEAK = WEAK_INDICES|WEAK_VALUES

Description

Flags for use together with set_weak_flag and get_weak_flag . See set_weak_flag for details.

  CLASS Pike.Backend


Method `()

void `()(float sleep_time)

Description

Perform one pass through the backend.

Parameter sleep_time

Wait at most sleep_time seconds.


Method add_file

void add_file(Stdio.File|Stdio.FILE f)

Description

Add f to this backend.


Method call_out

mixed call_out(function f, float|int delay, mixed ... args)

Description

Make a delayed call to a function.

call_out() places a call to the function f with the argument args in a queue to be called in about delay seconds.

Returns

Returns a call_out identifier that identifies this call_out. This value can be sent to eg find_call_out() or remove_call_out() .

See also

remove_call_out() , find_call_out() , call_out_info()


Method _do_call_outs

void _do_call_outs()

Description

Do all pending call_outs.

This function runs all pending call_outs that should have been run if Pike returned to the backend. It should not be used in normal operation.

As a side-effect, this function sets the value returned by time(1) to the current time.

See also

call_out() , find_call_out() , remove_call_out()


Method find_call_out

int find_call_out(function f)
int find_call_out(mixed id)

Description

Find a call out in the queue.

This function searches the call out queue. If given a function as argument, it looks for the first call out scheduled to that function.

The argument can also be a call out id as returned by call_out() , in which case that call_out will be found (Unless it has already been called).

Returns

find_call_out() returns the remaining time in seconds before that call_out will be executed. If no call_out is found, zero_type (find_call_out (f)) will return 1.

See also

call_out() , remove_call_out() , call_out_info()


Method remove_call_out

int remove_call_out(function f)
int remove_call_out(function id)

Description

Remove a call out from the call out queue.

This function finds the first call to the function f in the call_out queue and removes it. You can also give a call out id as argument (as returned by call_out).

Returns

The remaining time in seconds left to that call out will be returned. If no call_out was found, zero_type (remove_call_out (f )) will return 1.

See also

call_out_info() , call_out() , find_call_out()


Method call_out_info

array(array) call_out_info()

Description

Get info about all call_outs.

This function returns an array with one entry for each entry in the call out queue. The first in the queue will be at index 0. Each index contains an array that looks like this:

Array
int time_left

Time remaining in seconds until the call_out is to be performed.

object caller

The object that scheduled the call_out.

function fun

Function to be called.

mixed ... args

Arguments to the function.


See also

call_out() , find_call_out() , remove_call_out()

  Module Pike.Security

Description

Pike has an optional internal security system, which can be enabled with the configure-option --with-security.

The security system is based on attaching credential objects (Pike.Security.Creds ) to objects, programs, arrays, mappings or multisets.

A credential object in essence holds three values:

user -- The owner.

allow_bits -- Run-time access permissions.

data_bits -- Data access permissions.


Method call_with_creds

mixed Pike.Security.call_with_creds(Creds creds, mixed func, mixed ... args)

Description

Call with credentials.

Sets the current credentials to creds , and calls

func (@args )
. If creds is 0 (zero), the credentials from the current object will be used.

Note

The current creds or the current object must have the allow bit BIT_SECURITY set to allow calling with creds other than 0 (zero).


Method get_current_creds

Creds Pike.Security.get_current_creds()

Description

Get the current credentials

Returns the credentials that are currently active. Returns 0 (zero) if no credentials are active.

See also

call_with_creds()


Method get_object_creds

Creds Pike.Security.get_object_creds(object|program|function|array|mapping|multiset o)

Description

Get the credentials from o .

Returns 0 if o does not have any credentials.


Constant BIT_INDEX

constant Pike.Security.BIT_INDEX

Description

Allow indexing.


Constant BIT_SET_INDEX

constant Pike.Security.BIT_SET_INDEX

Description

Allow setting of indices.


Constant BIT_CALL

constant Pike.Security.BIT_CALL

Description

Allow calling of functions.


Constant BIT_SECURITY

constant Pike.Security.BIT_SECURITY

Description

Allow usage of security related functions.


Constant BIT_NOT_SETUID

constant Pike.Security.BIT_NOT_SETUID

Description

Don't change active credentials on function call.


Constant BIT_CONDITIONAL_IO

constant Pike.Security.BIT_CONDITIONAL_IO

FIXME

Document this constant.


Constant BIT_DESTRUCT

constant Pike.Security.BIT_DESTRUCT

Description

Allow use of destruct .

  CLASS Pike.Security.Creds

Description

The credentials object.


Method get_default_creds

Creds get_default_creds()

Description

Get the default credentials.

Returns the default credentials object if it has been set. Returns 0 (zero) if it has not been set.

See also

set_default_creds()


Method set_default_creds

void set_default_creds(Creds creds)

Description

Set the default credentials

Note

The current creds must have the allow bit BIT_SECURITY set.

See also

get_default_creds()


Method create

void Pike.Security.Creds(object user, int allow_bits, int data_bits)

Description

Initialize a new credentials object

Note

The current creds must have the allow bit BIT_SECURITY set.


Method get_user

object get_user()

Description

Get the user part.


Method get_allow_bits

int get_allow_bits()

Description

Get the allow_bit bitmask.


Method get_data_bits

int get_data_bits()

Description

Get the data_bits bitmask.


Method apply

void apply(object|program|function|array|mapping|multiset o)

Description

Set the credentials for o to this credentials object.

Note

To perform this operation the current credentials needs to have the bit BIT_SECURITY set, or have the same user as the old credentials and not change the user by performing the operation.

  Module Pike.DefaultBackend

Description

This is the Backend object that files and call_outs are handled by by default.

This is also the Backend object that will be used if main() returns -1.

See also

Backend , Stdio.File()->set_nonblocking() , call_out()

  Module Process


Method exec

int Process.exec(string file, string ... foo)


Method search_path

string Process.search_path(string command)


Method sh_quote

string Process.sh_quote(string s)


Method split_quoted_string

array(string) Process.split_quoted_string(string s, int(0..1)|void nt_mode)


Method spawn

Process Process.spawn(string s, object|void stdin, object|void stdout, object|void stderr, function|void cleanup, mixed ... args)


Method popen

string Process.popen(string s)


Method system

int Process.system(string s)

  CLASS Process.create_process

Description

This is the recommended and most portable way to start processes in Pike. The process object is a pike abstraction of the running system process, with methods for various process housekeeping.


Method wait

int wait()

Description

Waits for the process to end.

Returns

The exit code of the process.


Method status

int(-1..1) status()

Description

Returns the status of the process:

-1

Unknown

0

Running

1

Exited



Method pid

int pid()

Description

Returns the process identifier of the process.


Method set_priority

int set_priority(string priority)

Description

Sets the priority of the process. priority is one of the strings

realtime
highest
higher
high
low
lowest

Constant limit_value

constant limit_value = int|array(int|string)|mapping(string:int|string)|string

Description

Each limit_value may be either of:

integer

sets current limit, max is left as it is.

mapping

([ "hard":int, "soft":int ]) Both values are optional, hard <= soft.

array

({ hard, soft }), both can be set to the string "unlimited". A value of -1 means 'keep the old value'.

string

The string "unlimited" sets both the hard and soft limit to unlimited


Method create

void Process.create_process(array(string) command_args, void|mapping modifiers)

Parameter command_args

The command name and its command-line arguments. You do not have to worry about quoting them; pike does this for you.

Parameter modifiers

This optional mapping can can contain zero or more of the following parameters:

"cwd" : string

Execute the command in another directory than the current directory of this process. Please note that if the command is given is a relative path, it will be relative to this directory rather than the current directory of this process.

"stdin" : Stdio.File

These parameters allows you to change the standard input, output and error streams of the newly created process. This is particularly useful in combination with Stdio.File.pipe .

"stdout" : Stdio.File
"stderr" : Stdio.File
"env" : mapping(string:string)

This mapping will become the environment variables for the created process. Normally you will want to only add or change variables which can be achived by getting the environment mapping for this process with getenv . See the examples section.

"uid" : int|string

This parameter changes which user the new process will execute as. Note that the current process must be running as UID 0 to use this option. The uid can be given either as an integer as a string containing the login name of that user.

The "gid" and "groups" for the new process will be set to the right values for that user unless overriden by options below.

(See setuid and getpwuid for more info.)

"gid" : int|string

This parameter changes the primary group for the new process. When the new process creates files, they will will be created with this group. The group can either be given as an int or a string containing the name of the group. (See setuid and getgrgid for more info.)

"setsid" : int(0..1)|Stdio.File

Set this to 1 to create a new session group. It is also possible to set it to a File object, in which case a new session group will be created with this file as the controlling terminal.

"setgroups" : array(int|string)

This parameter allows you to the set the list of groups that the new process belongs to. It is recommended that if you use this parameter you supply at least one and no more than 16 groups. (Some system only support up to 8...) The groups can be given as gids or as strings with the group names.

"noinitgroups" : int(0..1)

This parameter overrides a behaviour of the "uid" parameter. If this parameter is used, the gid and groups of the new process will be inherited from the current process rather than changed to the approperiate values for that uid.

"priority" : string

This sets the priority of the new process, see set_priority for more info.

"nice" : int

This sets the nice level of the new process; the lower the number, the higher the priority of the process. Note that only UID 0 may use negative numbers.

"keep_signals" : int(0..1)

This prevents Pike from restoring all signal handlers to their default values for the new process. Useful to ignore certain signals in the new process.

"fds" : array(Stdio.File|int(0..0))

This parameter allows you to map files to filedescriptors 3 and up. The file fds[0] will be remapped to fd 3 in the new process, etc.

"rlimit" : mapping(string:limit_value)

There are two values for each limit, the soft limit and the hard limit. Processes that do not have UID 0 may not raise the hard limit, and the soft limit may never be increased over the hard limit. The indices of the mapping indicate what limit to impose, and the values dictate what the limit should be. (See also System.setrlimit )

"core" : limit_value

maximum core file size in bytes

"cpu" : limit_value

maximum amount of cpu time used by the process in seconds

"data" : limit_value

maximum heap (brk, malloc) size in bytes

"fsize" : limit_value

maximum size of files created by the process in bytes

"map_mem" : limit_value

maximum size of the process's mapped address space (mmap() and heap size) in bytes

"mem" : limit_value

maximum size of the process's total amount of available memory (mmap, heap and stack size) in bytes

"nofile" : limit_value

maximum number of file descriptors the process may create

"stack" : limit_value

maximum stack size in bytes



Example

Process.create_process(({ "/usr/bin/env" }), (["env" : getenv() + (["TERM":"vt100"]) ]));

Example

//! Spawn a new process with the args @[args] and optionally a //! standard input if you provide such a @[Stdio.File] object. //! @returns //! Returns the new process and a pipe from which you can read //! its output. array(Process.Process|Stdio.File) spawn(Stdio.File|void stdin, string ... args) { Stdio.File stdout = Stdio.File(); mapping opts = ([ "stdout" : stdout->pipe() ]); if( stdin ) opts->stdin = stdin; return ({ Process.create_process( args, opts ), stdout }); }

Note

All parameters that accept both string or int input can be noticeably slower using a string instead of an integer; if maximum performance is an issue, please use integers.

The modifiers "fds", "uid", "gid", "nice", "noinitgroups", "setgroups", "keep_signals" and "rlimit" only exist on unix.


Method kill

int kill(int signal)

Note

This function is only available on platforms that support signals.

  CLASS Process.Process


Inherit create_process

inherit __builtin.create_process : create_process


Method create

void Process.Process(string|array(string) args, mapping m)

  CLASS Process.Spawn


Method create

void Process.Spawn(string cmd, void|array(string) args, void|mapping(string:string) env, string|void cwd, void|array(Stdio.File|void) ownpipes, void|array(Stdio.File|void) fds_to_close)


Method kill

int kill(int signal)


Method wait

int wait()

  Module Thread


Method all_threads

array(Thread.Thread) Thread.all_threads()

Description

This function returns an array with the thread ids of all threads.

See also

Thread()


Method thread_set_concurrency

void Thread.thread_set_concurrency(int concurrency)

FIXME

Document this function


Method this_thread

Thread.Thread Thread.this_thread()

Description

This function returns the object that identifies this thread.

See also

Thread()


Inherit Thread

inherit Thread : Thread

  CLASS Thread.Thread


Method create

void Thread.Thread(function(mixed ... :void) f, mixed ... args)

Description

This function creates a new thread which will run simultaneously to the rest of the program. The new thread will call the function f with the arguments args . When f returns the thread will cease to exist.

All Pike functions are 'thread safe' meaning that running a function at the same time from different threads will not corrupt any internal data in the Pike process.

Returns

The returned value will be the same as the return value of this_thread() for the new thread.

Note

This function is only available on systems with POSIX or UNIX or WIN32 threads support.

See also

Mutex , Condition , this_thread()


Method backtrace

array(mixed) backtrace()

Description

Returns the current call stack for the thread.

Returns

The result has the same format as for predef::backtrace() .

See also

predef::backtrace()


Method status

int status()


Method _sprintf

string _sprintf(int c)

Description

Returns a string identifying the thread.


Method id_number

int id_number()

Description

Returns an id number identifying the thread.

Note

This function was added in Pike 7.2.204.


Method result

mixed result()

Description

Waits for the thread to complete, and then returns the value returned from the thread function.

  CLASS Thread.Mutex

Description

Mutex is a class that implements mutual exclusion locks. Mutex locks are used to prevent multiple threads from simultaneously execute sections of code which access or change shared data. The basic operations for a mutex is locking and unlocking. If a thread attempts to lock an already locked mutex the thread will sleep until the mutex is unlocked.

Note

This class is simulated when Pike is compiled without thread support, so it's always available.

In POSIX threads, mutex locks can only be unlocked by the same thread that locked them. In Pike any thread can unlock a locked mutex.


Method lock

MutexKey lock()
MutexKey lock(int type)

Description

This function attempts to lock the mutex. If the mutex is already locked by a different thread the current thread will sleep until the mutex is unlocked. The value returned is the 'key' to the lock. When the key is destructed or has no more references the mutex will automatically be unlocked. The key will also be destructed if the mutex is destructed.

The type argument specifies what lock() should do if the mutex is already locked by this thread:

0

Throw an error.

1

Sleep until the mutex is unlocked. Useful if some other thread will unlock it.

2

Return zero. This allows recursion within a locked region of code, but in conjunction with other locks it easily leads to unspecified locking order and therefore a risk for deadlocks.


See also

trylock()


Method trylock

MutexKey trylock()
MutexKey trylock(int type)

Description

This function performs the same operation as lock() , but if the mutex is already locked, it will return zero instead of sleeping until it's unlocked.

See also

lock()


Method current_locking_thread

Thread.Thread current_locking_thread()

Description

This mutex method returns the object that identifies the thread that has locked the mutex. 0 is returned if the mutex isn't locked.

See also

Thread()


Method current_locking_key

Thread.MutexKey current_locking_key()

Description

This mutex method returns the key object currently governing the lock on this mutex. 0 is returned if the mutex isn't locked.

See also

Thread()

  CLASS Thread.Condition

Description

Implementation of condition variables.

Condition variables are used by threaded programs to wait for events happening in other threads.

Note

Condition variables are only available on systems with thread support. The Condition class is not simulated otherwise, since that can't be done accurately without continuations.

See also

Mutex


Method wait

void wait(Thread.MutexKey mutex_key)

Description

Wait for contition.

This function makes the current thread sleep until the condition variable is signalled. The optional argument should be the 'key' to a mutex lock. If present the mutex lock will be unlocked before waiting for the condition in one atomic operation. After waiting for the condition the mutex referenced by mutex_key will be re-locked.

Note

In Pike 7.2 and earlier it was possible to call wait() without arguments. This possibility was removed in Pike 7.3, since it lead to programs with deadlocks.

See also

Mutex->lock()


Method signal

void signal()

Description

signal() wakes up one of the threads currently waiting for the condition.

Note

Sometimes more than one thread is woken up.

See also

broadcast()


Method broadcast

void broadcast()

Description

broadcast() wakes up all threads currently waiting for this condition.

See also

signal()

  CLASS Thread.Local

Description

Thread local variable storage.

This class allows you to have variables which are separate for each thread that uses it. It has two methods: get() and set() . A value stored in an instance of Local can only be retrieved by that same thread.

Note

This class is simulated when Pike is compiled without thread support, so it's always available.


Method get

mixed get()

Description

Get the thread local value.

This returns the value prevoiusly stored in the Local object by the set() method by this thread.

See also

set()


Method set

mixed set(mixed value)

Description

Set the thread local value.

This sets the value returned by the get method.

Calling this method does not affect the value returned by get() when it's called by another thread (ie multiple values can be stored at the same time, but only one value per thread).

Returns

This function returns its argument.

Note

Note that the value set can only be retreived by the same thread.

See also

get()

  CLASS Thread.Fifo

Description

Fifo implements a fixed length first-in, first-out queue. A fifo is a queue of values and is often used as a stream of data between two threads.

Note

Fifos are only available on systems with threads support.

See also

Queue


Inherit r_cond

inherit Condition : r_cond


Inherit w_cond

inherit Condition : w_cond


Inherit lock

inherit Mutex : lock


Method size

int size()

Description

This function returns the number of elements currently in the fifo.

See also

read() , write()


Method read

mixed read()

Description

This function retrieves a value from the fifo. Values will be returned in the order they were written. If there are no values present in the fifo the current thread will sleep until some other thread writes a value to the fifo.

See also

write() , read_array()


Method read_array

array read_array()

Description

This function returns all values currently in the fifo. Values in the array will be in the order they were written. If there are no values present in the fifo the current thread will sleep until some other thread writes a value to the fifo.

See also

write() , read()


Method write

void write(mixed value)

Description

Append a value to the end of the fifo. If there is no more room in the fifo the current thread will sleep until space is available.

See also

read()


Method create

void Thread.Fifo()
void Thread.Fifo(int size)

Description

Create a fifo. If the optional size argument is present it sets how many values can be written to the fifo without blocking. The default size is 128.

  CLASS Thread.Queue

Description

Queue implements a queue, or a pipeline. The main difference between Queue and Fifo is that Queue will never block in write(), only allocate more memory.

Note

Queues are only available on systems with POSIX or UNIX or WIN32 thread support.

See also

Fifo


Inherit r_cond

inherit Condition : r_cond


Inherit lock

inherit Mutex : lock


Method size

int size()

Description

This function returns the number of elements currently in the queue.

See also

read() , write()


Method read

mixed read()

Description

This function retrieves a value from the queue. Values will be returned in the order they were written. If there are no values present in the queue the current thread will sleep until some other thread writes a value to the queue.

See also

write()


Method write

void write(mixed value)

Description

This function puts a value last in the queue. If the queue is too small to hold the value the queue will be expanded to make room for it.

See also

read()

  Module Audio

  Module Audio.Format

Description

Audio data format handling

Note

API remains marked "unstable".

  CLASS Audio.Format.ANY


Method read_file

object read_file(string filename, int|void nocheck)

Description

Reads data from file

See also

read_streamed


Method read_streamed

object read_streamed(string filename, int|void nocheck)

Description

Reads data from stream

Ie. for packetized data source the beggining of data is searched.

See also

read_file


Method read_string

object read_string(string data, int|void nocheck)

Description

Reads data from string


Method get_frame

string get_frame()

Description

Returns frame for current position and moves cursor forward.

Note

The operation is destructive. Ie. current data cursor is moved over.

See also

get_data , get_sample


Method get_sample

mapping get_sample()

Description

Returns sample for current position and moves cursor forward.

Note

The operation is destructive. Ie. current data cursor is moved over.

See also

get_frame , get_data


Method get_data

string get_data()

Description

Returns data only.

Note

The operation is destructive. Ie. current data cursor is moved over.

See also

get_frame , get_sample


Method check_format

int check_format()

Description

Check if data are correctly formated.


Method get_map

mapping get_map()

  CLASS Audio.Format.MP3

Description

A MP3 file parser with ID3 tag support.


Inherit ANY

inherit .module.ANY : ANY


Method get_frame

mapping|int get_frame()

Description

Gets next frame from file

Frame is represented by the following mapping. It contains from parsed frame headers and frame data itself.

([ "bitrate": int "copyright": int(0..1), "data": frame_data, "emphasis": emphasis, "extension": "channels":0, "id":1, "layer":3, "original": int(0..1), "padding": int(0..1), "private": int(0..1), "sampling": int ])

  Module Audio.Codec

  CLASS Audio.Codec.decoder

Description

Decoder object.

Note

It needs _Ffmpeg.ffmpeg module for real work.


Method create

void Audio.Codec.decoder(string|void codecname, object|void _codec)

Description

Creates decoder object

Parameter codecnum

Some of supported codec, like _Ffmpeg.CODEC_ID_*

Parameter _codec

The low level object will be used for decoder. By default _Ffmpeg.ffmpeg object will be used.

Note

Until additional library is implemented the second parameter _codec hasn't effect.

See also

_Ffmpeg.ffmpeg , _Ffmpeg.CODEC_ID_MP2


Method from_file

object from_file(Audio.Format.ANY file)

Description

Set codec type from file

It uses Audio.Format.ANY 's method get_map() to determine which codec should be used.

Parameter file

The object Audio.Format.ANY .


Method decode

mapping|int decode(int|void partial)

Description

Decodes audio data

Parameter partial

Only one frame will be decoded per call.

Returns

If successfull a mapping with decoded data and byte number of used input data is returned, 0 otherwise.


Method get_status

mapping get_status()

Description

Returns decoder status

  Module Cache

  CLASS Cache.cache

Description

This module serves as a front-end to different kinds of caching systems. It uses two helper objects to actually store data, and to determine expiration policies. Mechanisms to allow for distributed caching systems will be added in time, or at least that is the plan.


Method lookup

mixed lookup(string key)

Description

Looks in the cache for an element with the given key and, if available, returns it. Returns 0 if the element is not available


Method alookup

void alookup(string key, function(string:void) callback, int|float timeout, mixed ... args)

Description

Asynchronously look the cache up. The callback will be given as arguments the key, the value, and then any user-supplied arguments. If the timeout (in seconds) expires before any data could be retrieved, the callback is called anyways, with 0 as value.


Method store

void store(string key, mixed value, void|int max_life, void|float preciousness, void|multiset(string) dependants)

Description

Sets some value in the cache. Notice that the actual set operation might even not happen at all if the set data doesn't make sense. For instance, storing an object or a program in an SQL-based backend will not be done, and no error will be given about the operation not being performed.

Notice that while max_life will most likely be respected (objects will be garbage-collected at pre-determined intervals anyways), the preciousness . is to be seen as advisory only for the garbage collector If some data was stored with the same key, it gets returned. Also notice that max_life is relative and in seconds. dependants are not fully implemented yet. They are implemented after a request by Martin Stjerrholm, and their purpose is to have some weak form of referential integrity. Simply speaking, they are a list of keys which (if present) will be deleted when the stored entry is deleted (either forcibly or not). They must be handled by the storage manager.


Method delete

void delete(string key, void|int(0..1) hard)

Description

Forcibly removes some key. If the 'hard' parameter is supplied and true, deleted objects will also have their lfun::destroy method called upon removal by some backends (i.e. memory)


Method start_cleanup_cycle

void start_cleanup_cycle()


Method async_cleanup_cache

void async_cleanup_cache()


Method threaded_cleanup_cycle

void threaded_cleanup_cycle()


Method create

void Cache.cache(Cache.Storage.Base storage_mgr, Cache.Policy.Base policy_mgr, void|int cleanup_cycle_delay)

Description

Creates a new cache object. Required are a storage manager, and an expiration policy object.

  Module Calendar

  CLASS Calendar.Calendar

Description

This is the base class of the calendars.


Method now

TimeRange now()

Description

Give the zero-length time period of the current time.

  CLASS Calendar.Ruleset

Description

This is the container class for rules.


Method set_abbr2zone

Ruleset set_abbr2zone(mapping(string:string) abbr2zone)

Description

Sets the guess-mapping for timezones. Default is the mapping

Abbreviation Interpretation
AMT          America/Manaus       [UTC-4]
AST          America/Curacao      [UTC-4]
CDT          America/Costa_Rica   [UTC-5]
CST          America/El Salvador  [UTC-6]
EST          America/Panama       [UTC-5]
GST          Asia/Dubai           [UTC+4]
IST          Asia/Jerusalem       [UTC+2]
WST          Australia/Perth      [UTC+8]

See also

YMD.parse

  CLASS Calendar.TimeRange

Description

This is the base class for any time measurement and calendrar information. It defines all the things you can do with a time range, any time period.

A TimeRange doubles as both a fixed period in time, and an amount of time. For instance, a week plus a day moves the week-period one day ahead (unaligning it with the week period, and thereby reducing it to just 7 days), no matter when in time the actual day were.


Method add

TimeRange add(int n, void|TimeRange step)

Description

calculates the (promoted) time period n steps away; if no step is given, the step's length is of the same length as the called time period.

It is not recommended to loop by adding the increment time period to a shorter period; this can cause faults, if the shorter time period doesn't exist in the incremented period. (Like week 53, day 31 of a month or the leap day of a year.)

Recommended use are like this:

   // loop over the 5th of the next 10 months
   TimeRange month=Month()+1;
   TimeRange orig_day=month()->day(5);
   for (int i=0; i<10; i++)
   {
      month++;
      TimeRange day=month->place(orig_day);
      ...use day...
   }


Method beginning
Method end

TimeRange beginning()
TimeRange end()

Description

This gives back the zero-sized beginning or end of the called time period.

rule: range(t->beginning(),t->end())==t


Method calendar

Calendar calendar()

Description

Simply gives back the calendar in use, for instance Calendar.ISO or Calendar.Discordian.


Method strictly_preceeds
Method preceeds
Method is_previous_to
Method overlaps
Method contains
Method equals
Method is_next_to
Method succeeds
Method strictly_succeeds

int(0..1) strictly_preceeds(TimeRange what)
int(0..1) preceeds(TimeRange what)
int(0..1) is_previous_to(TimeRange what)
int(0..1) overlaps(TimeRange what)
int(0..1) contains(TimeRange what)
int(0..1) equals(TimeRange what)
int(0..1) is_next_to(TimeRange what)
int(0..1) succeeds(TimeRange what)
int(0..1) strictly_succeeds(TimeRange what)

Description

These methods exists to compare two periods of time on the timeline.

          case            predicates
 
 <-- past       future ->
 
 |----A----|              A strictly preceeds B,
              |----B----| A preceeds B
 
 |----A----|              A strictly preceeds B, A preceeds B,
           |----B----|    A is previous to B, A touches B
 
     |----A----|          A preceeds B,
           |----B----|    A overlaps B, A touches B
 
     |-------A-------|    A preceeds B, A ends with B
           |----B----|    A overlaps B, A contains B, A touches B,
 
     |-------A-------|    A preceeds B,  A succeeds B,
         |---B---|        A overlaps B, A contains B, A touches B
 
        |----A----|       A overlaps B, A touches B, A contains B
        |----B----|       A equals B, A starts with B, A ends with B
 
     |-------A-------|    A succeeds B, A starts with B
     |----B----|          A overlaps B, A contains B, A touches B
 
           |----A----|    A succeeds B,
     |----B----|          A overlaps B, A touches B
 
           |----A----|    A strictly succeeds B, A succeeds B
 |----B----|              A is next to B, A touches B
 
             |----A----|  A strictly succeeds B,
 |----B----|              A succeeds B
 
 

Note

These methods only check the range of the first to the last time in the period; use of combined time periods (SuperTimeRange s) might not give you the result you want.

See also

`&amp;


Method create

void Calendar.TimeRange("unix", int unixtime)
void Calendar.TimeRange("unix", int unixtime, int seconds_len)

Description

Create the timerange from unix time (as given by time(2)), with eventually the size of the time range in the same unit, seconds.


Method create

void Calendar.TimeRange("julian", int|float julian_day)

Description

Create the timerange from a julian day, the standardized method of counting days. If the timerange is more then a day, it will at least enclose the day.


Method create

void Calendar.TimeRange(TimeRange from)

Description

Create the timerange from another timerange.

This is useful when converting objects from one calendar to another. Note that the ruleset will be transferred to the new object, so this method can't be used to convert between timezones or languges - use set_timezone , set_language or set_ruleset to achieve this.

Note

The size of the new object may be inexact; a Month object can't comprehend seconds, for instance.


Method range
Method space
Method distance

TimeRange range(TimeRange other)
TimeRange space(TimeRange other)
TimeRange distance(TimeRange other)

Description

Derives different time periods in between the called timerange and the parameter timerange.

>- the past          the future -<
 |--called--|         |--other--|
 >------------ range -----------<
            >--space--<
 >----- distance -----<
 

See also: add, TimeRanges.range, TimeRanges.space, TimeRanges.distance


Method `/
Method how_many

int `/(TimeRange with)
int how_many(TimeRange with)

Description

This calculates how many instances of the given timerange has passed during the called timerange.

For instance, to figure out your age, create the timerange of your lifespan, and divide with the instance of a Year .


Method set_language
Method language

TimeRange set_language(Language lang)
TimeRange set_language(string lang)
Language language()

Description

Set or get the current language rule.


Method next
Method prev

TimeRange next()
TimeRange prev()

Description

Next and prev are compatible and convinience functions; a->next() is exactly the same as a+1; a=a->next() is a++.


Method offset_to

int offset_to(TimeRange x)

Description

Calculates offset to x; this compares two timeranges and gives the integer offset between the two starting points.

This is true for suitable a and b: a+a->offset_to(b)==b

By suitable means that a and b are of the same type and size. This is obviously true only if a+n has b as a possible result for any n.


Method place

TimeRange place(TimeRange this)
TimeRange place(TimeRange this, int(0..1) force)

Description

This will place the given timerange in this timerange, for instance, day 37 in the year - Year(1934)->place(Day(1948 d37)) => Day(1934 d37).

Note

The rules how to place things in different timeranges can be somewhat 'dwim'.


Method set_ruleset
Method ruleset

TimeRange set_ruleset(Ruleset r)
TimeRange ruleset(Ruleset r)

Description

Set or get the current ruleset.

Note

this may include timezone shanges, and change the time of day.


Method set_size

TimeRange set_size(TimeRange size)
TimeRange set_size(int n, TimeRange size)

Description

Gives back a new (or the same, if the size matches) timerange with the new size. If n are given, the resulting size will be n amounts of the given size.

Note

A negative size is not permitted; a zero one are.


Method set_timezone
Method timezone

TimeRange set_timezone(Timezone tz)
TimeRange set_timezone(string tz)
TimeZone timezone()

Description

Set or get the current timezone (including dst) rule.

Note

The time-of-day may very well change when you change timezone.

To get the time of day for a specified timezone, select the timezone before getting the time of day:

Year(2003)->...->set_timezone(TimeZone.CET)->...->hour(14)->...


Method `/
Method split

array(TimeRange) `/(int n)
array(TimeRange) split(int n)

Description

This divides the called timerange into n pieces. The returned timerange type is not neccesarily of the same type as the called one.

known bugs: These are currently not defined for supertimeranges .


Method subtract

TimeRange subtract(TimeRange what)

Description

This subtracts a period of time from another;

>- the past          the future -<
|-------called-------|
     |-------other--------|
<---->  <- called->subtract(other)
 
|-------called-------|
     |---third---|
<---->           <---> <- called->subtract(third)


Method `&

TimeRange `&(TimeRange with)

Description

Gives the cut on the called time period with another time period. The result is zero if the two periods doesn't overlap.

>- the past          the future -<
 |-------called-------|
      |-------other--------|
      >----- cut -----<
 


Method `*

TimeRange `*(int n)

Description

This changes the amount of time in the time period. t*17 is the same as doing t->set_size (t,17).


Method `+
Method `-

TimeRange `+(int n)
TimeRange `+(TimeRange offset)
TimeRange `-(int m)
TimeRange `-(TimeRange x)

Description

This calculates the (promoted) time period either n step away or with a given offset. These functions does use add to really do the job:

t+n         t->add(n)             t is a time period
t-n         t->add(-n)            offset is a time period
t+offset    t->add(1,offset)      n is an integer
t-offset    t->add(-1,offset)
n+t         t->add(n)
n-t         illegal
offset+t    offset->add(1,t)      | note this!
offset-t    offset->add(-1,t)     |

Mathematic rules:

x+(t-x) == t    x is an integer or a time period
(x+t)-x == t    t is a time period
(t+x)-x == t
o-(o-t) == t    o is a time period
t++ == t+1
t-- == t-1

Note

a-b does not give the distance between the start of a and b. Use the distance () function to calculate that.

The integer used to `+, `- and add are the number of steps the motion will be. It does never represent any fixed amount of time, like seconds or days.


Method `<
Method `>

int(0..1) `<(TimeRange compared_to)
int(0..1) `>(TimeRange compared_to)

Description

These operators sorts roughty on the periods place in time. The major use might be to get multiset to work, besides sorting events clearly defined in time.


Method `==
Method _equal

int(0..1) `==(TimeRange compared_to)
int(0..1) _equal(TimeRange compared_to)

Description

These two overloads the operator `== and the result of the equal function.

a==b is considered true if the two timeranges are of the same type, have the same rules (language, timezone, etc) and are the same timerange.

equal(a,b) are considered true if a and b are the same timerange, exactly the same as the equals method.

The __hash method is also present, to make timeranges possible to use as keys in mappings.

known bugs: _equal is not currently possible to overload, due to wierd bugs, so equal uses `== for now.


Method `^

TimeRange `^(TimeRange with)

Description

Gives the exclusive-or on the called time period and another time period, ie the union without the cut. The result is zero if the two periods were the same.

>- the past          the future -<
 |-------called-------|
      |-------other--------|
 <----|               |---->   - exclusive or
 


Method `|

TimeRange `|(TimeRange with)

Description

Gives the union on the called time period and another time period.

>- the past          the future -<
 |-------called-------|
      |-------other--------|
 <----------union---------->
 

  CLASS Calendar.SuperTimeRange

Description
inherits TimeRange

This class handles the cases where you have a time period with holes. These can be created by the ^ or | operators on time ranges.


Constant nulltimerange

constant nulltimerange = TimeRange

Description

This represents the null time range, which, to differ from the zero time range (the zero-length time range), isn't placed in time. This is the result of for instance `& between two strict non-overlapping timeranges - no time at all.

It has a constant, is_nulltimerange, which is non-zero. `! on this timerange is true.


Method create

void Calendar.SuperTimeRange(array(TimeRange) parts)

Description

A SuperTimeRange must have at least two parts, two time ranges. Otherwise, it's either not a time period at all or a normal time period.

  Module Calendar.Austrian

Description

Same as the ISO calendar, but with austrian as the default language.

This calendar exist only for backwards compatible purposes.

  Module Calendar.Coptic

Description

This is the Coptic Orthodox Church calendar, that starts the 11th or 12th September and has 13 months.

Note

The (default) names of the months are different then other the emacs calendar; I do not know which ones are used - the difference seem to be only the transcription of the phonetic sounds (B <-> P, etc).

I do not know for how long back the calendar is valid, either. My sources claim that the calendar is synchronized with the Gregorian calendar, which is odd.

  Module Calendar.Discordian

Description

The Discordian calendar, as described on page 34 in the fourth edition of Principia Discordia.

Chaotic enough, it's quite simpler then the Gregorian calendar; weeks are 5 days, and evens up on a year. Months are 73 days.

The leap day is inserted at the 60th day of the first month (Chaos), giving the first month 74 days. The description of the calendar is a "perpetual date converter from the gregorian to the POEE calendar", so the leap years are the same as the gregorians.

The Principia calls months "seasons", but for simplicity I call them months in this calendar.

If anyone know more about how to treat the leap day - now it is inserted in the month and week where it lands, rather then being separated from month and weeks, I'm interested to know.

- Mirar, Pope of POEE.

  Module Calendar.Event

  CLASS Calendar.Event.Event

Description

Event is a base class, defining what methods an Event need to have.


Method next
Method previous

TimeRange next(TimeRange from, void|int(0..1) including)
TimeRange previous(TimeRange from, void|int(0..1) including)

Description

This calculates the next or previous occurance of the event, from the given timerange's start, including any event occuring at the start if that flag is set.

It returns zero if there is no next event.

This method is virtual in the base class.


Method scan

array(TimeRange) scan(TimeRange in)

Description

This calculates the eventual events that is contained or overlapped by the given timerange.

Example: Event.christmas_eve->scan(Year(2000)) => ({ Day(Sun 24 Dec 2000) })

scan uses next if not overloaded.

Note

scan can return an array of overlapping timeranges.

This method must use in->calendar_object->type to create the returned timeranges, and must keep the ruleset.

  CLASS Calendar.Event.Day_Event

Description

Day_Event is a base class, extending Event for events that are single days, using julian day numbers for the calculations.


Method scan
Method next

array(TimeRange) scan(TimeRange in)
TimeRange next(TimeRange from)
TimeRange next(TimeRange from, int(0..1) including)

Description

These methods are implemented, using the virtual method scan_jd .

See also

Event


Method scan_jd

int scan_jd(Calendar realm, int jd, int(-1..-1)|object|int(1..1) direction)

Description

These methods has to be defined, and is what really does some work. It should return the next or previos julian day (>jd) when the event occurs, or the constant NODAY if it doesn't.

direction1 is forward (next), -1 is backward (previous).

  CLASS Calendar.Event.Nameday

Description

This is created by the Namedays classes to represent an event for a name.

  CLASS Calendar.Event.Namedays

Description
inherits Event

This contains a ruleset about namedays.


Method namedays

mapping(TimeRange:array(string)) namedays(TimeRange t)

Description

Gives back an table of days with names that occur during the time period. Note that days without names will not appear in the returned mapping.


Method names

array(string) names(TimeRange t)

Description

Gives back an array of names that occur during the time period, in no particular order.


Method previous
Method next

TimeRange previous(TimeRange from, void|int(0..1) including)
TimeRange next(TimeRange from, void|int(0..1) including)

  CLASS Calendar.Event.Date

Description

This class represents the event of a given gregorian date. For instance, Event.Date(12,10)->next(Day()) finds the next 12 of October.


Method create

void Calendar.Event.Date(int month_day, int month)

Description

The event is created by a given month day and a month number (1=January, 12=December).

  CLASS Calendar.Event.Date_Weekday

Description

This class represents the event that a given gregorian date appears a given weekday. For instance, Event.Date_Weekday(12,10,5)->next(Day()) finds the next 12 of October that is a friday.


Method create

void Calendar.Event.Date_Weekday(int month_day, int month, int weekday)

Description

The event is created by a given month day, a month number (1=January, 12=December), and a weekday number (1=Monday, 7=Sunday).

Note

The week day numbers used are the same as the day of week in the ISO calendar - the Gregorian calendar has 1=Sunday, 7=Saturday.

  CLASS Calendar.Event.Monthday_Weekday

Description

This class represents the event that a given gregorian day of month appears a given weekday. For instance, Event.Monthday_Weekday(13,5)->next(Day()) finds the next friday the 13th.


Method create

void Calendar.Event.Monthday_Weekday(int month_day, int weekday)

Description

The event is created by a given month day, and a weekday number (1=Monday, 7=Sunday).

Note

The week day numbers used are the same as the day of week in the ISO calendar - the Gregorian calendar has 1=Sunday, 7=Saturday.

  CLASS Calendar.Event.Weekday

Description

This class represents any given weekday. For instance, Event.Weekday(5)->next(Day()) finds the next friday.

These are also available as the pre-defined events "monday", "tuesday", "wednesday", "thursday", "friday", "saturday" and "sunday".


Method create

void Calendar.Event.Weekday(int weekday)

Description

The event is created by a given weekday number (1=Monday, 7=Sunday).

Note

The week day numbers used are the same as the day of week in the ISO calendar - not the Gregorian or Julian calendar that has 1=Sunday, 7=Saturday.

  CLASS Calendar.Event.SuperEvent

Description

This class holds any number of events, and adds the functionality of event flags.

Note

Scanning (scan_events,next,etc) will drop flag information. Dig out what you need with ->holidays et al first.


Method filter_flag
Method holidays
Method flagdays

SuperEvent filter_flag(string flag)
SuperEvent holidays()
SuperEvent flagdays()

Description

Filter out the events that has a certain flag set. Holidays (flag "h") are the days that are marked red in the calendar (non-working days), Flagdays (flag "f") are the days that the flag should be visible in (only some countries).

  Module Calendar.Gregorian

Description

This is the standard conservative christian calendar, used regularly in some countries - USA, for instance - and which derivate - the ISO calendar - is used in most of europe.

  Module Calendar.ISO

Description
inherits Gregorian

This is the standard western calendar, which is a derivate of the Gregorian calendar, but with weeks that starts on monday instead of sunday.

  Module Calendar.Islamic

Description

This is the islamic calendar. Due to some sources, they decide the first day of the new months on a month-to-month basis (sightings of the new moon), so it's probably not that accurate. If someone can confirm (or deny) accuracy better than that, please contact me so I can change this statement.

It's vaugely based on rules presented in algorithms by Dershowitz, Reingold and Clamen, 'Calendrical Calculations'. It is the same that's used in Emacs calendar mode.

known bugs: I have currently no idea how the arabic countries count the week. Follow the same rules as ISO for now... The time is also suspicious; the *day* really starts at sunrise (sunset?) and not midnight, the hours of the day is not correct. Also don't know what to call years before 1 - go for "BH"; positive years are "AH", anno Hegirac.

  Module Calendar.Julian

Description
inherits YMD

This is the Julian calendar, conjured up by the old Romans when their calendar were just too wierd. It was used by the christians as so far as the 18th century in some parts of the world. (Especially the protestantic and orthodox parts.)

Note

Don't confuse the julian day with the Julian calendar. The former is just a linear numbering of days, used in the Calendar module as a common unit for absolute time.

  Module Calendar.Roman

Description

base for all Roman-kind of calendars ie, one with years, months, weeks and days

  Module Calendar.Stardate

Description

This implements TNG stardates.


Method create

void Calendar.Stardate.(mixed ...)
void Calendar.Stardate.(int|float date)
void Calendar.Stardate.()

Description

Apart from the standard creation methods (julian day, etc), you can create a stardate from the stardate number. The length of the period will then be zero.

You can also omit any arguments to create now.

known bugs: Since the precision is limited to the float type of pike you can get non-precise results:

    > Calendar.Second(Calendar.Stardate.Day(Calendar.Year()));
    Result: Second(Fri 31 Dec 1999 23:59:18 CET - Sun 31 Dec 2000 23:59:18 CET)
    


Method now

TimeofDay Calendar.Stardate.now()

Description

Give the zero-length time period of the current time.


Method number_of_seconds
Method number_of_days

int Calendar.Stardate.number_of_seconds()
int Calendar.Stardate.number_of_days()

Description

This gives back the Gregorian/Earth/ISO number of seconds and number of days, for convinience and conversion to other calendars. string format_long(void|int precision) string format_short(void|int precision) string format_vshort(void|int precision) Format the stardate tick nicely. Precision is the number of decimals. Defaults to 3.

       long    "-322537.312"
       short   "77463.312"  (w/o >100000-component)
       vshort  "7463.312"  (w/o >10000-component)
    


Method tics

float Calendar.Stardate.tics()

Description

This gives back the number of stardate tics in the period.

  Module Calendar.Swedish

Description

Same as the ISO calendar, but with swedish as the default language.

This calendar exist only for backwards compatible purposes.

  Module Calendar.TZnames

Description

This module contains listnings of available timezones, in some different ways


Constant zones

constant Calendar.TZnames.zones = mapping(string:array(string))

Description

This constant is a mapping that can be used to loop over to get all the region-based timezones.

It looks like this:

([ "America": ({ "Los_Angeles", "Chicago", [...] }),
   "Europe":  ({ "Stockholm", [...] }),
   [...] }),

Please note that loading all the timezones can take some time, since they are generated and compiled on the fly.


Constant abbr2zones

constant Calendar.TZnames.abbr2zones = mapping(string:array(string))

Description

This mapping is used to look up abbreviation to the possible regional zones.

It looks like this:

([ "CET": ({ "Europe/Stockholm", [...] }),
   "CST": ({ "America/Chicago", "Australia/Adelaide", [...] }),
   [...] }),

Note this: Just because it's noted "CST" doesn't mean it's a unique timezone. There is about 7 *different* timezones that uses "CST" as abbreviation; not at the same time, though, so the DWIM routines checks this before it's satisfied. Same with some other timezones.

For most timezones, there is a number of region timezones that for the given time are equal. This is because region timezones include rules about local summer time shifts and possible historic shifts.

The YMD.parse functions can handle timezone abbreviations by guessing.


Method zonenames

array(string) Calendar.TZnames.zonenames()

Description

This reads the zone.tab file and returns name of all standard timezones, like "Europe/Belgrade".


Method _zone_tab
Method zone_tab

string Calendar.TZnames._zone_tab()
array(array) Calendar.TZnames.zone_tab()

Description

This returns the raw respectively parsed zone tab file from the timezone data files.

The parsed format is an array of zone tab line arrays,

({ string country_code,
   string position,
   string zone_name,
   string comment })

To convert the position to a Geography.Position, simply feed it to the constructor.

  Module Calendar.Time

Description

Base for time of day in calendars, ie calendars with hours, minutes, seconds

This module can't be used by itself, but is inherited by other modules (ISO by YMD , for instance).

  CLASS Calendar.Time.TimeofDay


Method create

void Calendar.Time.TimeofDay()
void Calendar.Time.TimeofDay(int unixtime)

Description

In addition to the wide range of construction arguments for a normal TimeRange (see TimeRange.create ), a time of day can also be constructed with unixtime as single argument consisting of the unix time - as returned from time(2) - of the time unit start.

It can also be constructed without argument, which then means "now", as in "this minute".


Method format_iso_ymd
Method format_ymd
Method format_ymd_short
Method format_ymd_xshort
Method format_iso_week
Method format_iso_week_short
Method format_week
Method format_week_short
Method format_month
Method format_month_short
Method format_iso_time
Method format_time
Method format_time_short
Method format_iso_short
Method format_time_xshort
Method format_mtime
Method format_xtime
Method format_tod
Method format_xtod
Method format_mod
Method format_nice
Method format_nicez

string format_iso_ymd()
string format_ymd()
string format_ymd_short()
string format_ymd_xshort()
string format_iso_week()
string format_iso_week_short()
string format_week()
string format_week_short()
string format_month()
string format_month_short()
string format_iso_time()
string format_time()
string format_time_short()
string format_iso_short()
string format_time_xshort()
string format_mtime()
string format_xtime()
string format_tod()
string format_xtod()
string format_mod()
string format_nice()
string format_nicez()

Description

Format the object into nice strings;

iso_ymd        "2000-06-02 (Jun) -W22-5 (Fri)" [2]
ext_ymd        "Friday, 2 June 2000" [2]
ymd            "2000-06-02"
ymd_short      "20000602"
ymd_xshort     "000602" [1]
iso_week       "2000-W22"
iso_week_short "2000W22"
week           "2000-w22" [2]
week_short     "2000w22" [2]
month          "2000-06"
month_short    "200006" [1]
iso_time       "2000-06-02 (Jun) -W22-5 (Fri) 20:53:14 UTC+1" [2]
ext_time       "Friday, 2 June 2000, 20:53:14" [2]
ctime          "Fri Jun  4 20:53:14 2000\n" [2] [3]
http           "Fri, 02 Jun 2000 19:53:14 GMT" [4]
time           "2000-06-02 20:53:14"
time_short     "20000602 20:53:14"
time_xshort    "000602 20:53:14"
iso_short      "20000602T20:53:14"
mtime          "2000-06-02 20:53"
xtime          "2000-06-02 20:53:14.000000"
todz           "20:53:14 CET"
todz_iso       "20:53:14 UTC+1"
tod            "20:53:14"
tod_short      "205314"
xtod           "20:53:14.000000"
mod            "20:53"
nice           "2 Jun 20:53", "2 Jun 2000 20:53:14" [2][5]
nicez          "2 Jun 20:53 CET" [2][5]
smtp           "Fri, 2 Jun 2000 20:53:14 +0100" [6]
[1] note conflict (think 1 February 2003)
[2] language dependent
[3] as from the libc function ctime()
[4] as specified by the HTTP standard; this is always in GMT, ie, UTC. The timezone calculations needed will be executed implicitly. It is not language dependent.
[5] adaptive to type and with special cases for yesterday, tomorrow and other years
[6] as seen in Date: headers in mails


Method hour_no
Method minute_no
Method second_no
Method fraction_no

int hour_no()
int minute_no()
int second_no()
float fraction_no()

Description

This gives back the number of the time unit, on this day. Fraction is a float number, 0<=fraction<1. function mapping datetime() This gives back a mapping with the relevant time information (representing the start of the period);

     ([ "year":     int        // year number (2000 AD=2000, 1 BC==0)
        "month":    int(1..)   // month of year
        "day":      int(1..)   // day of month
        "yearday":  int(1..)   // day of year
        "week":     int(1..)   // week of year
        "week_day": int(1..)   // day of week (depending on calendar)
 
        "hour":     int(0..)   // hour of day, including dst
        "minute":   int(0..59) // minute of hour
        "second":   int(0..59) // second of minute
        "fraction": float      // fraction of second
        "timezone": int        // offset to utc, including dst
 
        "unix":     int        // unix time
        "julian":   float      // julian day
     ]);
    


Method hour
Method hours
Method number_of_hours

Hour hour()
Hour hour(int n)
array(Hour) hours()
array(Hour) hours(int first, int last)
int number_of_hours()

Description

hour () gives back the timerange representing the first or nth Hour of the called object. Note that hours normally starts to count at zero, so ->hour(2) gives the third hour within the range.

An Hour is in the Calendar perspective as any other time range not only 60 minutes, but also one of the (normally) 24 hours of the day, precisely.

hours () give back an array of all the hours containing the time periods called. With arguments, it will give back a range of those hours, in the same enumeration as the n to hour ().

number_of_hours () simple counts the number of hours containing the called time period.

Note: The called object doesn't have to *fill* all the hours it will send back, it's enough if it exist in those hours:

    > object h=Calendar.Time.Hour();
    Result: Hour(265567)
    > h->hours();
    Result: ({ /* 1 element */
                Hour(265567)
            })
    > h+=Calendar.Time.Minute();
    Result: Minute(265567:01+60m)
    > h->hours();
    Result: ({ /* 2 elements */
                Hour(265567),
                Hour(265568)
            })
    


Method julian_day

float julian_day()

Description

This calculates the corresponding julian day, from the time range. Note that the calculated day is the beginning of the period, and is a float - julian day standard says .00 is midday, 12:00 pm.

Note

Normal pike (ie, 32 bit) floats (without --with-double-precision) has a limit of about 7 digits, and since we are about julian day 2500000, the precision on time of day is very limited.


Method minute
Method minutes
Method number_of_minutes

Minute minute()
Minute minute(int n)
array(Minute) minutes()
array(Minute) minutes(int first, int last)
int number_of_minutes()

Description

minute () gives back the timerange representing the first or nth Minute of the called object. Note that minutes normally starts to count at zero, so ->minute(2) gives the third minute within the range.

An Minute is in the Calendar perspective as any other time range not only 60 seconds, but also one of the (normally) 60 minutes of the Hour , precisely.

minutes () give back an array of all the minutes containing the time periods called. With arguments, it will give back a range of those minutes, in the same enumeration as the n to minute ().

number_of_minutes () simple counts the number of minutes containing the called time period.


Method move_seconds
Method move_ns

TimeRange move_seconds(int seconds)
TimeRange move_ns(int nanoseconds)

Description

These two methods gives back the time range called moved the specified amount of time, with the length intact.

The motion is relative to the original position in time; 10 seconds ahead of 10:42:32 is 10:42:42, etc.


Method second
Method seconds
Method number_of_seconds

Second second()
Second second(int n)
array(Second) seconds()
array(Second) seconds(int first, int last)
int number_of_seconds()

Description

second () gives back the timerange representing the first or nth Second of the called object. Note that seconds normally starts to count at zero, so ->second(2) gives the third second within the range.

seconds () give back an array of all the seconds containing the time periods called. With arguments, it will give back a range of those seconds, in the same enumeration as the n to second ().

number_of_seconds () simple counts the number of seconds containing the called time period.


Method set_size_seconds
Method set_size_ns

TimeRange set_size_seconds(int seconds)
TimeRange set_size_ns(int nanoseconds)

Description

These two methods allows the time range to be edited by size of specific units.


Method unix_time

int unix_time()

Description

This calculates the corresponding unix time, - as returned from time(2) - from the time range. Note that the calculated unix time is the beginning of the period.

  CLASS Calendar.Time.SuperTimeRange


Method second
Method seconds
Method number_of_seconds
Method minute
Method minutes
Method number_of_minutes
Method hour
Method hours
Method number_of_hours

Second second()
Second second(int n)
array(Second) seconds()
array(Second) seconds(int first, int last)
int number_of_seconds()
Minute minute()
Minute minute(int n)
array(Minute) minutes()
array(Minute) minutes(int first, int last)
int number_of_minutes()
Hour hour()
Hour hour(int n)
array(Hour) hours()
array(Hour) hours(int first, int last)
int number_of_hours()

Description

Similar to TimeofDay , the Time::SuperTimeRange has a number of methods for digging out time parts of the range. Since a SuperTimeRange is a bit more complex - the major reason for its existance it that it contains holes, this calculation is a bit more advanced too.

If a range contains the seconds, say, 1..2 and 4..5, the third second (number 2, since we start from 0) in the range would be number 4, like this:

no   means this second
0    1
1    2
2    4      <- second three is missing,
3    5         as we don't have it in the example range

number_of_seconds () will in this example therefore also report 4, not 5, even if the time from start of the range to the end of the range is 5 seconds.

  CLASS Calendar.Time.Fraction

Description
inherits TimeofDay

A Fraction is a part of a second, and/or a time period with higher resolution then a second.

It contains everything that is possible to do with a Second , and also some methods of grabbing the time period with higher resolution.

Note

Internally, the fraction time period is measured in nanoseconds. A shorter or more precise time period then in nanoseconds is not possible within the current Fraction class.


Method create

void Calendar.Time.Fraction()
void Calendar.Time.Fraction("unixtime", int|float unixtime)
void Calendar.Time.Fraction("unixtime", int|float unixtime, int|float len)

Description

It is possible to create a Fraction in two ways, either "now" with no arguments or from a unix time (as from time(2)).

If created from unix time, both the start of the period and the size of the period can be given in floats, both representing seconds. Note that the default float precision in pike is rather low (same as 'float' in C, the 32 bit floating point precision, normally about 7 digits), so beware that the resolution might bite you. (Internally in a Fraction, the representation is an integer.)

If created without explicit length, the fraction will always be of zero length.


Method now

TimeofDay now()

Description

Give the zero-length time period of the current time.


Method set_ruleset
Method ruleset

Calendar set_ruleset(Ruleset r)
Ruleset ruleset()

Description

Set or read the ruleset for the calendar. set_ruleset returns a new calendar object, but with the new ruleset.


Method set_timezone
Method timezone

Calendar set_timezone(Timezone tz)
Calendar set_timezone(string|Timezone tz)
TimeZone timezone()

Description

Set or get the current timezone (including dst) rule. set_timezone returns a new calendar object, as the called calendar but with another set of rules.

Example:

> Calendar.now();
Result: Fraction(Fri 2 Jun 2000 18:03:22.010300 CET)
> Calendar.set_timezone(Calendar.Timezone.UTC)->now();
Result: Fraction(Fri 2 Jun 2000 16:03:02.323912 UTC)

  Module Calendar.Timezone

Description

This module contains all the predefined timezones. Index it with whatever timezone you want to use.

Example: Calendar.Calendar my_cal= Calendar.ISO->set_timezone(Calendar.Timezone["Europe/Stockholm"]);

A simpler way of selecting timezones might be to just give the string to set_timezone ; it indexes by itself:

Calendar.Calendar my_cal= Calendar.ISO->set_timezone("Europe/Stockholm");

Note

Do not confuse this module with Ruleset.Timezone , which is the base class of a timezone object.

"CET" and some other standard abbreviations work too, but not all of them (due to more then one country using them).

Do not call set_timezone too often, but remember the result if possible. It might take some time to initialize a timezone object.

There are about 504 timezones with 127 different daylight saving rules. Most of them historic.

The timezone information comes from ftp://elsie.nci.nih.gov/pub/ and are not made up from scratch. Timezone bugs may be reported to the timezone mailing list, tz@elsie.nci.nih.gov, preferable with a cc to mirar@mirar.org. /Mirar

See also

TZnames , Ruleset.Timezone


Constant locale

constant Calendar.Timezone.locale = Ruleset.Timezone

Description

This contains the local timezone, found from various parts of the system, if possible.


Constant localtime

constant Calendar.Timezone.localtime = Ruleset.Timezone

Description

This is a special timezone, that uses localtime () and tzname to find out what current offset and timezone string to use.

locale uses this if there is no other way of finding a better timezone to use.

This timezone is limited by localtime and libc to the range of time_t, which is a MAXINT on most systems - 13 Dec 1901 20:45:52 to 19 Jan 2038 3:14:07, UTC.

  Module Calendar.YMD

Description

base for all Roman-kind of Calendars, ie, one with years, months, weeks and days

  CLASS Calendar.YMD.YMD

Description
inherits TimeRange

Base (virtual) time period of the Roman-kind of calendar.


Method format_iso_ymd
Method format_ymd
Method format_ymd_short
Method format_ymd_xshort
Method format_iso_week
Method format_iso_week_short
Method format_week
Method format_week_short
Method format_month
Method format_month_short
Method format_iso_time
Method format_time
Method format_time_short
Method format_time_xshort
Method format_mtime
Method format_xtime
Method format_tod
Method format_todz
Method format_xtod
Method format_mod

string format_iso_ymd()
string format_ymd()
string format_ymd_short()
string format_ymd_xshort()
string format_iso_week()
string format_iso_week_short()
string format_week()
string format_week_short()
string format_month()
string format_month_short()
string format_iso_time()
string format_time()
string format_time_short()
string format_time_xshort()
string format_mtime()
string format_xtime()
string format_tod()
string format_todz()
string format_xtod()
string format_mod()

Description

Format the object into nice strings;

iso_ymd        "2000-06-02 (Jun) -W22-5 (Fri)" [2]
ext_ymd        "Friday, 2 June 2000" [2]
ymd            "2000-06-02"
ymd_short      "20000602"
ymd_xshort     "000602" [1]
iso_week       "2000-W22"
iso_week_short "2000W22"
week           "2000-w22" [2]
week_short     "2000w22" [2]
month          "2000-06"
month_short    "200006" [1]
iso_time       "2000-06-02 (Jun) -W22-5 (Fri) 00:00:00 UTC+1" [2]
ext_time       "Friday, 2 June 2000, 00:00:00" [2]
ctime          "Fri Jun  2 00:00:00 2000\n" [2] [3]
http           "Fri, 02 Jun 2000 00:00:00 GMT" [4]
time           "2000-06-02 00:00:00"
time_short     "20000602 00:00:00"
time_xshort    "000602 00:00:00"
iso_short      "2000-06-02T00:00:00"
mtime          "2000-06-02 00:00"
xtime          "2000-06-02 00:00:00.000000"
tod            "00:00:00"
tod_short      "000000"
todz           "00:00:00 CET"
todz_iso       "00:00:00 UTC+1"
xtod           "00:00:00.000000"
mod            "00:00"
[1] note conflict (think 1 February 2003)
[2] language dependent
[3] as from the libc function ctime()
[4] as specified by the HTTP standard; not language dependent.


Method fraction_no
Method hour_no
Method julian_day
Method leap_year
Method minute_no
Method month_day
Method month_no
Method second_no
Method utc_offset
Method week_day
Method week_no
Method year_day
Method year_no
Method month_name
Method month_shortname
Method month_day_name
Method week_day_name
Method week_day_shortname
Method week_name
Method year_name
Method tzname
Method tzname_iso

float fraction_no()
int hour_no()
int julian_day()
int leap_year()
int minute_no()
int month_day()
int month_no()
int second_no()
int utc_offset()
int week_day()
int week_no()
int year_day()
int year_no()
string month_name()
string month_shortname()
string month_day_name()
string week_day_name()
string week_day_shortname()
string week_name()
string year_name()
string tzname()
string tzname_iso()

Description

function method int unix_time() Returns the unix time integer corresponding to the start of the time range object. (An unix time integer is UTC.) function method datetime() This gives back a mapping with the relevant time information (representing the start of the period);

     ([ "year":     int        // year number (2000 AD=2000, 1 BC==0)
        "month":    int(1..)   // month of year
        "day":      int(1..)   // day of month
        "yearday":  int(0..)   // day of year
        "week":     int(1..)   // week of year
        "week_day": int(0..)   // day of week
        "timezone": int        // offset to utc, including dst
 
        "unix":     int        // unix time
        "julian":   int        // julian day
     // for compatibility:
        "hour":     0          // hour of day, including dst
        "minute":   0          // minute of hour
        "second":   0          // second of minute
        "fraction": 0.0        // fraction of second
     ]);
    

Note

Day of week is compatible with old versions, ie, 0 is sunday, 6 is saturday, so it shouldn't be used to calculate the day of the week with the given week number. Year day is also backwards compatible, ie, one (1) less then from the year_day() function.


Method second
Method minute
Method seconds
Method number_of_seconds
Method minutes
Method number_of_minutes
Method hour
Method hours
Method number_of_hours

Second second()
Second second(int n)
Minute minute(int hour, int minute, int second)
array(Second) seconds()
array(Second) seconds(int first, int last)
int number_of_seconds()
Minute minute()
Minute minute(int n)
Minute minute(int hour, int minute)
array(Minute) minutes()
array(Minute) minutes(int first, int last)
int number_of_minutes()
Hour hour()
Hour hour(int n)
array(Hour) hours()
array(Hour) hours(int first, int last)
int number_of_hours()

  CLASS Calendar.YMD.Year

Description
inherits TimeRange
inherits YMD

This is the time period of a year.


Method create

void Calendar.YMD.Year("unix", int unix_time)
void Calendar.YMD.Year("julian", int|float julian_day)
void Calendar.YMD.Year(int year)
void Calendar.YMD.Year(string year)

Description

It's possible to create the standard week by using three different methods; either the normal way - from standard unix time or the julian day, and also, for more practical use, from the year number.


Method month

Month month()
Month month(int n)
Month month(string name)

Description

The Year type overloads the month() method, so it is possible to get a specified month by string:

year->month("April")

The integer and no argument behavior is inherited from YMD ().


Method week

Week week()
Week week(int n)
Week week(string name)

Description

The Year type overloads the week() method, so it is possible to get a specified week by name:

year->week("17") year->week("w17")

The integer and no argument behavior is inherited from YMD ().

This is useful, since the first week of a year not always (about half the years, in the ISO calendar) is numbered '1'.

  CLASS Calendar.YMD.Week

Description

The Calendar week represents a standard time period of a week. In the Gregorian calendar, the standard week starts on a sunday and ends on a saturday; in the ISO calendar, it starts on a monday and ends on a sunday.

The week are might not be aligned to the year, and thus the week may cross year borders and the year of the week might not be the same as the year of all the days in the week. The basic rule is that the week year is the year that has the most days in the week, but since week number only is specified in the ISO calendar - and derivates - the week number of most calendars is the week number of most of the days in the ISO calendar, which modifies this rule for the Gregorian calendar; the week number and year is the same as for the ISO calendar, except for the sundays.

When adding, moving and subtracting months to a week, it falls back to using days.

When adding, moving or subtracting years, if tries to place the moved week in the resulting year.


Method create

void Calendar.YMD.Week("unix", int unix_time)
void Calendar.YMD.Week("julian", int|float julian_day)
void Calendar.YMD.Week(int year, int week)

Description

It's possible to create the standard week by using three different methods; either the normal way - from standard unix time or the julian day, and also, for more practical use, from year and week number.


Method create

void Calendar.YMD.Week("unix", int unix_time)
void Calendar.YMD.Week("julian", int|float julian_day)
void Calendar.YMD.Week(int year, int month, int day)
void Calendar.YMD.Week(int year, int year_day)
void Calendar.YMD.Week(int julian_day)

Description

It's possible to create the day by using five different methods; either the normal way - from standard unix time or the julian day, and also, for more practical use, from year, month and day, from year and day of year, and from julian day without extra fuzz.


Method day

Day day()
Day day(int n)
Day day(string name)

Description

The Week type overloads the day() method, so it is possible to get a specified weekday by string:

week->day("sunday")

The integer and no argument behavior is inherited from YMD ().

Note

the weekday-from-string routine is language dependent.

  CLASS Calendar.YMD.Hour

Description
inherits Time.Hour
inherits YMD

global convinience functions


Method parse

TimeRange parse(string fmt, string arg)

Description

parse a date, create relevant object fmt is in the format "abc%xdef..." where abc and def is matched, and %x is one of those time units:

%Y absolute year
%y dwim year (70-99 is 1970-1999, 0-69 is 2000-2069)
%M month (number, name or short name) (needs %y)
%W week (needs %y)
%D date (needs %y, %m)
%d short date (20000304, 000304)
%a day (needs %y)
%e weekday (needs %y, %w)
%h hour (needs %d, %D or %W)
%m minute (needs %h)
%s second (needs %m)
%S seconds since the Epoch (only combines with %f)
%f fraction of a second (needs %s or %S)
%t short time (205314, 2053)
%z zone
%p "am" or "pm"
%n empty string (to be put at the end of formats)

Returns

0 if format doesn't match data, or the appropriate time object.

Note

The zone will be a guess if it doesn't state an exact regional timezone (like "Europe/Stockholm") - most zone abbriviations (like "CET") are used by more then one region with it's own daylight saving rules. Also beware that for instance CST can be up to four different zones, central Australia or America being the most common.

    Abbreviation Interpretation
    AMT          America/Manaus       [UTC-4]
    AST          America/Curacao      [UTC-4]
    CDT          America/Costa_Rica   [UTC-6]
    CST          America/El Salvador  [UTC-6]
    EST          America/Panama       [UTC-5]
    GST          Asia/Dubai           [UTC+4]
    IST          Asia/Jerusalem       [UTC+2]
    WST          Australia/Perth      [UTC+8]
    

This mapping is modifiable in the ruleset, see Ruleset.set_abbr2zone . function Day dwim_day(string date) function Day dwim_day(string date,TimeRange context) Tries a number of different formats on the given date (in order):

parse  format                  as in
    "%y-%M-%D (%M) -W%W-%e (%e)"  "2000-03-20 (Mar) -W12-1 (Mon)"
    "%y-%M-%D"                    "2000-03-20", "00-03-20"
    "%M%/%D/%y"                   "3/20/2000"
    "%D%*[ /]%M%*[ /-,]%y"        "20/3/2000" "20 mar 2000" "20/3 -00"
    "%e%*[ ]%D%*[ /]%M%*[ /-,]%y" "Mon 20 Mar 2000" "Mon 20/3 2000"
    "-%y%*[ /]%D%*[ /]%M"         "-00 20/3" "-00 20 mar"
    "-%y%*[ /]%M%*[ /]%D"         "-00 3/20" "-00 march 20"
    "%y%*[ /]%D%*[ /]%M"          "00 20 mar" "2000 20/3"
    "%y%*[ /]%M%*[ /]%D"          "2000 march 20"
    "%D%.%M.%y"                   "20.3.2000"
    "%D%*[ -/]%M"                 "20/3" "20 mar" "20-03"
    "%M%*[ -/]%D"                 "3/20" "march 20"
    "%M-%D-%y"                    "03-20-2000"
    "%D-%M-%y"                    "20-03-2000"
    "%e%*[- /]%D%*[- /]%M"        "mon 20 march"
    "%e%*[- /]%M%*[- /]%D"        "mon/march/20"
    "%e%*[ -/wv]%W%*[ -/]%y"      "mon w12 -00" "1 w12 2000"
    "%e%*[ -/wv]%W"               "mon w12"
    "%d"                          "20000320", "000320"
    "today"                       "today"
    "last %e"                     "last monday"
    "next %e"                     "next monday"
    

Casts exception if it fails to dwim out a day. "dwim" means do-what-i-mean.

function datetime(int|void unix_time) Replacement for localtime; gives back a mapping:

     ([ "year":     int        // year number (2000 AD=2000, 1 BC==0)
        "month":    int(1..)   // month of year
        "day":      int(1..)   // day of month
        "yearday":  int(1..)   // day of year
        "week":     int(1..)   // week of year
        "week_day": int(1..)   // day of week (depending on calendar)
        "unix":     int        // unix time
        "julian":   float      // julian day
        "hour":     int(0..)   // hour of day, including dst
        "minute":   int(0..59) // minute of hour
        "second":   int(0..59) // second of minute
        "fraction": float      // fraction of second
        "timezone": int        // offset to utc, including dst
     ]);
    
This is the same as calling Second ()->datetime ().

function datetime_name(int|void unix_time) function datetime_short_name(int|void unix_time) Compat functions; same as format_iso and format_iso_short .

function string format_iso(void|int unix_time) function string format_iso_short(void|int unix_time) function string format_iso_tod(void|int unix_time) function string format_day_iso(void|int unix_time) function string format_day_iso_short(void|int unix_time) Format the object into nice strings;

    iso    "2000-06-02 (Jun) -W22-5 (Fri) 11:57:18 CEST"
    iso_short   "2000-06-02 11:57:18"
    iso_tod     "11:57:18"
    

  Module Calendar_I

Description

This module exist only for backwards compatibility issues with earlier Pike releases. Use the Calendar module instead.

This code can be used to simulate the old calendar for now (it might be removed in later Pike's):

This module has been totally rewritten in Pike 7.1+. To be forward compatible the lazy way, you can do something like this, though:


   #if constant(Calendar.II)
   #define Calendar Calendar_I
   #endif
   ... import Calendar or whatever ...

This module implements calendar calculations, and base classes for time units.

  CLASS Calendar_I._TimeUnit

Description

class time_unit


Method lesser

array(string) lesser()

Description

Gives a list of methods to get lesser (shorter) time units. ie, for a month, this gives back

({"day"})
and the method
day(mixed n)
gives back that day object. The method
days()
gives back a list of possible argument values to the method day. Concurrently,
Array.map(o->days(),o->day)
gives a list of day objects in the object o.

Ie:

	  array(string) lesser()    - gives back a list of possible xxx's.
	  object xxxs()             - gives back a list of possible n's.
	  object xxx(mixed n)       - gives back xxx n
	  object xxx(object(Xxx) o) - gives back the corresponing xxx 
	

The list of n's (as returned from xxxs) are always in order.

There are two n's with special meaning, 0 and -1. 0 always gives the first xxx, equal to

my_obj->xxx(my_obj->xxxs()[0])
, and -1 gives the last, equal to
my_obj->xxx(my_obj->xxxs()[-1])
.

To get all xxxs in the object, do something like

Array.map(my_obj->xxxs(),my_obj->xxx)
.

xxx(object) may return zero, if there was no correspondning xxx.


Method greater

array(string) greater()

Description

Gives a list of methods to get greater (longer) time units from this object. For a month, this gives back

({"year"})
, thus the method
month->year()
gives the year object.


Method next
Method prev
Method `+
Method `-

object next()
object prev()
object `+(int n)
object `-(int n)
object `-(object x)

Description

next() and prev() give the logical next and previous object. The `+() operator gives that logical relative object, ie

my_day+14
gives 14 days ahead. `-() works the same way, but can also take an object of the same type and give the difference as an integer.

  Module Calendar_I.Gregorian

Description

time units: Year , Month , Week , Day


Method parse

object Calendar_I.Gregorian.parse(string fmt, string arg)

Description

Parse a date, create relevant object fmt is in the format "abc%xdef..." where abc and def is matched, and %x is one of those time units: %Y absolute year %y year (70-99 is 1970-1999, 0-69 is 2000-2069) %M month (number, name or short name) (needs %y) %W week (needs %y) %D date (needs %y, %m) %a day (needs %y) %e weekday (needs %y, %w) %h hour (needs %d, %D or %W) %m minute (needs %h) %s second (needs %s)


Method datetime

mapping(string:int) Calendar_I.Gregorian.datetime(int|void unix_time, int|void skip_extra)

Description

Replacement for localtime.


Method datetime_name

string Calendar_I.Gregorian.datetime_name(int|void unix_time)

Description

Replacement for ctime.


Method datetime_short_name

string Calendar_I.Gregorian.datetime_short_name(int|void unix_time)

Description

Replacement for ctime.

  CLASS Calendar_I.Gregorian.Year

Description

A Calendar_I.time_unit

Lesser units: Month , Week , Day Greater units: none


Inherit _TimeUnit

inherit _TimeUnit : _TimeUnit

  Module Calendar_I.Stardate

Description

time unit: TNGDate

  CLASS Calendar_I.Stardate.TNGDate

Description

Implements ST:TNG stardates. Can be used as create argument to Day.


Inherit _TimeUnit

inherit Calendar_I._TimeUnit : _TimeUnit

  Module Debug


Method pp_memory_usage

string Debug.pp_memory_usage()

Description

Returns a pretty printed version of the output from memory_usage .


Method verify_internals

void Debug.verify_internals()

Description

Perform sanity checks.

This function goes through most of the internal Pike structures and generates a fatal error if one of them is found to be out of order. It is only used for debugging.

Note

This function does a more thorough check if the Pike runtime has been compiled with RTL debug.


Method debug

int Debug.debug(int(0..) level)

Description

Set the run-time debug level.

Returns

The old debug level will be returned.

Note

This function is only available if the Pike runtime has been compiled with RTL debug.


Method optimizer_debug

int Debug.optimizer_debug(int(0..) level)

Description

Set the optimizer debug level.

Returns

The old optimizer debug level will be returned.

Note

This function is only available if the Pike runtime has been compiled with RTL debug.


Method assembler_debug

int Debug.assembler_debug(int(0..) level)

Description

Set the assembler debug level.

Returns

The old assembler debug level will be returned.

Note

This function is only available if the Pike runtime has been compiled with RTL debug.


Method compiler_trace

int Debug.compiler_trace(int(0..) level)

Description

Set the compiler trace level.

Returns

The old compiler trace level will be returned.

Note

This function is only available if the Pike runtime has been compiled with RTL debug.


Method memory_usage

mapping(string:int) Debug.memory_usage()

Description

Check memory usage.

This function is mostly intended for debugging. It delivers a mapping with information about how many arrays/mappings/strings etc. there are currently allocated and how much memory they use.

Note

Exactly what this function returns is version dependant.

See also

_verify_internals()


Method reset_dmalloc

void Debug.reset_dmalloc()

Note

Only available when compiled with dmalloc.


Method dmalloc_set_name

void Debug.dmalloc_set_name(string filename, int linenumber)

Note

Only available when compiled with dmalloc.


Method list_open_fds

void Debug.list_open_fds()

Note

Only available when comiled with dmalloc.


Method locate_references

mapping(string:int) Debug.locate_references(string|array|mapping|multiset|function|object|program|type o)

Description

This function is mostly intended for debugging. It will search through all data structures in Pike looking for o and print the locations on stderr. o can be anything but int or float.

Note

This function only exists if the Pike runtime has been compiled with RTL debug.


Method describe

mixed Debug.describe(mixed x)

Description

Prints out a description of the thing x to standard error. The description contains various internal info associated with x .

Note

This function only exists if the Pike runtime has been compiled with RTL debug.


Method gc_set_watch

void Debug.gc_set_watch(array|multiset|mapping|object|function|program|string x)

Description

Sets a watch on the given thing, so that the gc will print a message whenever it's encountered. Intended to be used together with breakpoints to debug the garbage collector.

Note

This function only exists if the Pike runtime has been compiled with RTL debug.


Method dump_backlog

void Debug.dump_backlog()

Description

Dumps the 1024 latest executed opcodes, along with the source code lines, to standard error. The backlog is only collected on debug level 1 or higher, set with _debug or with the -d argument on the command line.

Note

This function only exists if the Pike runtime has been compiled with RTL debug.


Method gc_status

mapping(string:int|float) Debug.gc_status()

Description

Get statistics from the garbage collector.

Returns

A mapping with the following content will be returned:

"num_objects" : int

Number of objects.

"num_allocs" : int

Number of memory allocations.

"alloc_threshold" : int

Threshold where the garbage-collector starts.

"objects_alloced" : int

Number of allocated objects.

"objects_freed" : int

Number of freed objects.

"last_gc" : int

Time when the garbage-collector last ran.

"projected_garbage" : float

Heuristic for the amount of garbage in the system.


See also

gc()


Method describe_program

array(array(int|string)) Debug.describe_program(program p)

Description

Debug function for showing the symbol table of a program.

  CLASS Debug.Subject

Description

This is a probe subject which you can send in somewhere to get probed (not to be confused with a probe object, which does some active probing). All calls to LFUNs will be printed to stderr. It is possible to name the subject by passing a string as the first and only argument when creating the subject object.

Example

> object s = Debug.Subject(); create() > random(s); _random() (1) Result: 0 > abs(s); `<(0) _sprintf(79, ([ "indent":2 ])) (2) Result: Debug.Subject > abs(class { inherit Debug.Subject; int `<(mixed ... args) { return 1; } }()); create() `-() destroy() (3) Result: 0 > pow(s,2); `[]("pow") Attempt to call the NULL-value Unknown program: 0(2)

  CLASS Debug.Tracer

Description

A class that when instatiated will turn on trace, and when it's destroyed will turn it off again.


Method create

void Debug.Tracer(int level)

Description

Sets the level of debug trace to level .

  Module Filesystem


Method parse_mode

int Filesystem.parse_mode(int old, int|string mode)

Description

FIXME: Document this function


Method get_filesystem

program Filesystem.get_filesystem(string what)

Description

FIXME: Document this function


Method `()

function Filesystem.`()(void|string path)

Description

FIXME: Document this function

  CLASS Filesystem.System

Description

Implements an abstraction of the normal filesystem.


Inherit Base

inherit Filesystem.Base : Base


Method create

void Filesystem.System(void|string directory, void|string root, void|int fast, void|Filesystem.Base parent)

Description

Instanciate a new object representing the filesystem.

Parameter directory

The directory (in the real filesystem) that should become the root of the filesystemobject.

Parameter root

Internal

Parameter fast

Internal

Parameter parent

Internal

  CLASS Filesystem.Stat

Description

Describes the stat of a file


Method isfifo
Method ischr
Method isdir
Method isblk
Method isreg
Method islnk
Method issock
Method isdoor

int(0..1) isfifo()
int(0..1) ischr()
int(0..1) isdir()
int(0..1) isblk()
int(0..1) isreg()
int(0..1) islnk()
int(0..1) issock()
int(0..1) isdoor()

Description
fifo

Is the file a FIFO?

chr

Is the file a character device?

dir

Is the file (?) a directory?

blk

Is the file a block device?

reg

Is the file a regular file?

lnk

Is the file a link to some other file or directory?

sock

Is the file a socket?

door

FIXME: Document this function.

Returns

1 if the file is of a specific type 0 if the file is not.

See also

[set_type]


Method set_type

void set_type(string x)

Description

Set a type for the stat-object.

Note

This call doesnot change the filetype in the underlaying filesystem.

Parameter x

Type to set. Type is one of the following:

  • fifo, chr, dir, blk, reg, lnk, sock and door
See also

[isfifo], [ischr], [isdir], [isblk], [isreg], [islnk], [issock], [isdoor]


Method attach_statarray

void attach_statarray(array(int) a)

Description

Fills the stat-object with data from a Stdio.File.stat() call.


Method open

Stdio.File open(string mode)

Description

Open the stated file within the filesystem

Returns

a [Stdio.File] object

See also

[Stdio.File]


Method cd

object cd()

Description

Change to the stated directory.

Returns

the directory if the stated object was a directory, 0 otherwise.


Method nice_date

string nice_date()

Description

Returns the date of the stated object as cleartext.

  CLASS Filesystem.Base

Description

Baseclass that can be extended to create new filesystems. Is used by the Tar and System filesystem classes.


Method cd

Base cd(string|void directory)

Description

Change directory within the filesystem. Returns a new filesystem object with the given directory as cwd.


Method cwd

string cwd()

Description

Returns the current working directory within the filesystem.


Method chroot

Base chroot(void|string directory)

Description

Change the root of the filesystem.


Method stat

Stat stat(string file, int|void lstat)

Description

Return a stat-object for a file or a directory within the filesystem.


Method get_dir

array(string) get_dir(void|string directory, void|string|array glob)

Description

Returns an array of all files and directories within a given directory.

Parameter directory

Directory where the search should be made within the filesystem. CWD is assumed if none (or 0) is given.

Parameter glob

Return only files and dirs matching the glob (if given).

See also

[get_stats]


Method get_stats

array(Stat) get_stats(void|string directory, void|string|array glob)

Description

Returns stat-objects for the files and directories matching the given glob within the given directory.

See also

[get_dir]


Method open

Stdio.File open(string filename, string mode)

Description

Open a file within the filesystem

Returns

A Stdio.File object.


Method apply

int apply()

Description

FIXME: Document this function


Method chmod

void chmod(string filename, int|string mode)

Description

Change mode of a file or directory.


Method chown

void chown(string filename, int|object owner, int|object group)

Description

Change ownership of the file or directory


Method mkdir

int mkdir(string directory, void|int|string mode)

Description

Create a new directory


Method rm

int rm(string filename)

Description

Remove a file from the filesystem.


Method find

array find(void|function(Stat:int) mask, mixed ... extra)

Description

FIXME: Document this function

  Module Filesystem.Tar

Description

Filesystem which can be used to mount a Tar file.


Method create

void Filesystem.Tar.(string filename, void|Filesystem.Base parent)

Parameter filename

The tar file to mount.

Parameter parent

The parent filesystem. If non is given, the normal system filesystem is assumed. This allows mounting a TAR-file within a tarfile.

  Module Geography

  CLASS Geography.Position

Description

This class contains a geographical position, ie a point on the earths surface. The resulting position object implements comparision methods (__hash, `==, `< and `>) so that you can compare and sort positions as well as using them as index in mappings. Comparision is made primary on latidue and secondly on longitude. It does not currently take the ellipsoid into account.

It is possible to cast a position into an array, which will yield ({ float latitude, float longitude }), as well as into a string.


Variable lat

float lat

Description

Latitude (N--S) of the position, in degrees. Positive number is north, negative number is south.


Variable long

float long

Description

Longitude (W--E) of the position, in degrees. Positive number is east, negative number is west.


Variable alt

float alt

Description

Altitud of the position, in meters. Positive numbers is up. Zero is the shell of the current ellipsoid.


Method create

void Geography.Position(float lat, float long, void|float alt)
void Geography.Position(string lat, string long)
void Geography.Position(string both)

Description

Constructor for this class. If feeded with strings, it will perform a dwim scan on the strings. If they fails to be understood, there will be an exception.


Method latitude
Method longitude

string latitude(void|int n)
string longitude(void|int n)

Description

Returns the nicely formatted latitude or longitude.

0

"17°42.19'N" / "42°22.2'W"

1

"17.703°N" / "42.37°W"

2

"17°42.18'N" / "42°22.2'W"

3

"17°42'10.4"N" / "42°22'12"W"

-1

"17.703" / "-42.37"



Method standard_grid

string standard_grid()

Description

Returns the standard map grid system for the current position. Can either be "UPS" or "UTM".


Variable polar_radius

float polar_radius

Description

The polar radius is how many meters the earth radius is at the poles (north-south direction).


Variable equatorial_radius

float equatorial_radius

Description

The equatorial radius is how many meters the earth radius is at the equator (east-west direction).


Method flattening

float flattening()

Description

Returns the flattening factor for the selected earth approximation ellipsoid.


Method eccentricity_squared

float eccentricity_squared()

Description

Returns the first eccentricity squared for the selected earth approximation ellipsoid.


Constant ellipsoids

constant ellipsoids

Description

A mapping with reference ellipsoids, which can be fed to the UTM converter. The mapping maps the name of the ellipsoid to an array where the first element is a float describing the equatorial radius and the second element is a float describing the polar radius.


Method set_ellipsoid

int(0..1) set_ellipsoid(string name)
int(0..1) set_ellipsoid(float equatorial_radius, float polar_radius)

Description

Sets the equatorial and polar radius to the provided values. A name can also be provided, in which case the radius will be looked up in the ellipsoid mapping. The function returns 1 upon success, 0 on failure.

"Airy 1830"
"ATS77"
"Australian National"
"Bessel 1841"
"Bessel 1841 Namibia"
"Clarke 1866"
"Clarke 1880"
"Everest"
"Everest 1830"
"Everest 1848"
"Everest 1856"
"Everest 1869"
"Everest Pakistan"
"Fisher 1960"
"Fisher 1968"
"G R S 1967"
"G R S 1975"
"G R S 1980"
"Helmert 1906"
"Hough 1956"
"Indonesian 1974"
"Krassovsky 1940"
"Mercury"
"Modified Airy"
"Modified Fisher 1960"
"New International 1967"
"SGS 85"
"South American 1969"
"Sphere"
"WGS 60"
"WGS 66"
"WGS 72"
"WGS 84"

Note

The longitude and lattitude are not converted to the new ellipsoid.


Method UTM_zone_number

int UTM_zone_number()

Description

Returns the UTM zone number for the current longitude, with correction for the Svalbard deviations.


Method UTM_zone_designator

string UTM_zone_designator()

Description

Returns the UTM letter designator for the current latitude. Returns "Z" if latitude is outside the UTM limits of 84N to 80S.


Method UTM_offset

array(float) UTM_offset()

Description

Returns the offset within the present UTM cell. The result will be returned in an array of floats, containing easting and northing.


Method UTM

string UTM()

Description

Returns the current UTM coordinates position. An example output is "32T 442063.562 5247479.500" where the parts are zone number + zone designator, easting and northing.


Method set_from_UTM

void set_from_UTM(int zone_number, string zone_designator, float UTME, float UTMN)

Description

Sets the longitude and lattitude from the given UTM coordinates.


Method GEOREF

string GEOREF()

Description

Gives the full GEOREF position for the current position, e.g. "LDJA0511".


Method approx_height

float approx_height()

Description

Returns a very crude approximation of where the ground level is at the current position, compared against the ellipsoid shell. WGS-84 is assumed, but the approximation is so bad that it doesn't matter which of the standard ellipsoids is used.


Method ECEF

array(float) ECEF()

Description

Returns the current position as Earth Centered Earth Fixed Cartesian Coordinates.

Returns

({ X, Y, Z })


Method __hash

int __hash()


Method `==

int `==(object pos)


Method `<

int `<(object pos)


Method `>

int `>(object pos)


Method _sprintf

string _sprintf(int|void t)

  Module Geography.Countries


Variable countries

array(Country) Geography.Countries.countries

Description

All known countries.


Method from_domain

Country Geography.Countries.from_domain(string domain)

Description

Look up a country from a domain name. Returns zero if the domain doesn't map to a country. Note that there are some valid domains that don't:

INT

International

MIL

US Military

NET

Network

ORG

Non-Profit Organization

ARPA

Old style Arpanet

NATO

Nato field

And that US has five domains, Great Britain and france two: <dl compact> <dt>EDU <dd>US Educational <dt>MIL <dd>US Military <dt>GOV <dd>US Government <dt>UM <dd>US Minor Outlying Islands <dt>US <dd>US <dt>GB <dd>Great Britain (UK) <dt>UK <dd>United Kingdom <dt>FR <dd>France <dt>FX <dd>France, Metropolitan <dt>There's also three domains that for convinience maps to US: <dt>NET <dd>Network <dt>ORG <dd>Organization <dt>COM <dd>Commercial </dl>


Method from_domain

Country Geography.Countries.from_domain(string name)

Description

Look up a country from its name or aka. The search is case-insensitive but regards whitespace and interpunctation.


Method continents

mapping(string:array(Country)) Geography.Countries.continents()

Description

Gives back a mapping from continent name to an array of the countries on that continent.

The continents are:

    	  "Europe"
    	  "Africa"
    	  "Asia"
    	  "North America"
    	  "South America"
    	  "Oceania"
	  "Antarctica"
	

Note

Some countries are considered to be on more than one continent.


Method `[]
Method `->

mixed Geography.Countries.`[](string what)
mixed Geography.Countries.`->(string what)

Description

Convenience functions for getting a country the name-space way; it looks up whatever it is in the name- and domain-space and returns that country if possible:

> Geography.Countries.se; Result: Country(Sweden) > Geography.Countries.djibouti; Result: Country(Djibouti) > Geography.Countries.com; Result: Country(United States) > Geography.Countries.wallis_and_futuna_islands->iso2; Result: "WF"

  CLASS Geography.Countries.Country

Description

Country


Variable iso2

string iso2

Description

ISO 2-character code aka domain name


Variable fips10

string fips10

Description

FIPS 10-character code; "Federal Information Processing Standards 10-3" etc, used by some goverments in the US.


string name
array(string) aka

Description

Country name and as-known-as, if any


Variable former

int former

Description

Flag that is set if this country doesn't exist anymore. (eg USSR.)


Method continent

string continent()

Description

Returns the continent of the country.

Note

Some countries are geographically in more then one continent; any of the continents might be returned then, but probably the continent in which the capital is resident - Europe for Russia, for instance.


Method cast

string cast("string")

Description

It is possible to cast a country to a string, which will be the same as performing

country->name;
.

  Module Graphics

  Module Graphics.Graph


Inherit "polyline.pike"

inherit "polyline.pike"


Inherit "create_graph.pike"

inherit "create_graph.pike"


Inherit "create_bars.pike"

inherit "create_bars.pike"


Inherit "create_pie.pike"

inherit "create_pie.pike"


Inherit "create_graph.pike"

inherit "create_graph.pike"


Method check_mapping

mapping(string:mixed) Graphics.Graph.check_mapping(mapping(string:mixed) diagram_data, string type)

Description

This function sets all unset elements in diagram_data to its default value as well as performing some simple sanity checks. This function is called from within pie , bars , sumbars , line , norm and graph .


Method pie

Image.Image Graphics.Graph.pie(mapping(string:mixed) diagram_data)

FIXME

Document this function


Method bars

Image.Image Graphics.Graph.bars(mapping(string:mixed) diagram_data)

FIXME

Document this function


Method sumbars

Image.Image Graphics.Graph.sumbars(mapping(string:mixed) diagram_data)

FIXME

Document this function


Method line

Image.Image Graphics.Graph.line(mapping(string:mixed) diagram_data)

FIXME

Document this function


Method norm

Image.Image Graphics.Graph.norm(mapping(string:mixed) diagram_data)

FIXME

Document this function


Method graph

Image.Image Graphics.Graph.graph(mapping(string:mixed) diagram_data)

FIXME

Document this function

  Module Languages

  Module Languages.PLIS

Description

PLIS, Permuted Lisp. A Lisp language somewhat similar to scheme.


Method init_specials

void Languages.PLIS.init_specials(Environment environment)

Description

Adds the special functions quote, set!, setq, while, define, defmacro, lambda, if, and, or, begin and catch to the environment .


Method init_functions

void Languages.PLIS.init_functions(Environment environment)

Description

Adds the functions +, *, -, =, <, >, concat, read-string, eval, apply, global-environment, var, cdr, null?, setcar!, setcdr!, cons and list to the environment .


Method default_environment

Environment Languages.PLIS.default_environment()

Description

Creates a new environment on which it runs init_functions, init_specials and the following boot code.


 (begin
   (defmacro (cddr x)
     (list (quote cdr) (list (quote cdr) x)))
   (defmacro (cadr x)
     (list (quote car) (list (quote cdr) x)))
   (defmacro (cdar x)
     (list (quote cdr) (list (quote car) x)))
   (defmacro (caar x)
     (list (quote car) (list (quote car) x)))

   (defmacro (when cond . body)
     (list (quote if) cond
 	  (cons (quote begin) body)))

   (define (map fun list)
     (if (null? list) (quote ())
       (cons (fun (car list))
 	         (map fun (cdr list)))))

   (defmacro (let decl . body)
     (cons (cons (quote lambda)
 		(cons (map car decl) body))
 	  (map cadr decl))))
 


Method main

void Languages.PLIS.main()

Description

Instantiates a copy of the default environment and starts an interactive main loop that connects to standard I/O. The main loop is as follows:


 (begin
    (define (loop)
      (let ((line (read-line \"PLIS: \")))
          (if line
              (let ((res (catch (eval (read-string line)
                                     (global-environment)))))
                 (display res)
                (loop)))))
    (loop))
 

  Module Standards

  CLASS Standards.RDF

Description

Represents an RDF domain which can contain any number of complete statements.


Method add_statement

void add_statement(Resource subj, Resource pred, Resource obj)

Description

Adds a statement to the RDF set.


Method get_resource

Resource get_resource(string uri)

Description

Returns an RDF resource with the given URI as identifier, or zero.


Method find_statements

array(array(Resource)) find_statements(Resource|int(0..0) subj, Resource|int(0..0) pred, Resource|int(0..0) obj)

Description

Returns an array with the statements that matches the given subject subj , predicate pred and object obj . Any and all of the resources may be zero to disregard from matching that part of the statement, i.e. find_statements(0,0,0) returns all statements in the domain.

Returns

An array with arrays of three elements.

Array
Resource 0

The subject of the statement

Resource 1

The predicate of the statement

Resource 2

The object of the statement



Method get_n_triples

string get_n_triples()

Description

Returns an N-triples serialization of all the statements in the RDF set.


Method parse_n_triples

int parse_n_triples(string in)

Description

Parses an N-triples string and adds the found statements to the RDF set. Returns the number of added relations.

Throws

The parser will throw errors on invalid N-triple input.


Method decode_n_triple_string

string decode_n_triple_string(string in)

Description

Decodes a string that has been encoded for N-triples serialization.

Bugs

Doesn't correctly decode backslashes that has been encoded with with \u- or \U-notation.


Method encode_n_triple_string

string encode_n_triple_string(string in)

Description

Encodes a string for use as tring in N-triples serialization.

  CLASS Standards.RDF.Resource

Description

Instances of this class represents resources as defined in RDF: All things being described by RDF expressions are called resources. A resource may be an entire Web page; such as the HTML document "http://www.w3.org/Overview.html" for example. A resource may be a part of a Web page; e.g. a specific HTML or XML element within the document source. A resource may also be a whole collection of pages; e.g. an entire Web site. A resource may also be an object that is not directly accessible via the Web; e.g. a printed book. This general resource is anonymous and has no URI or literal id.

Note

Resources instantiated from this class should not be used in other RDF domain objects.

See also

URIResource , LiteralResource


Method get_n_triple_name

string get_n_triple_name()

Description

Returns the nodes' N-triple serialized ID.

  CLASS Standards.RDF.LiteralResource

Description

Resource identified by literal.


Inherit Resource

inherit Resource : Resource


Method create

void Standards.RDF.LiteralResource(string literal)

Description

The resource will be identified by literal .

  CLASS Standards.RDF.URIResource

Description

Resource identified by URI.


Inherit Resource

inherit Resource : Resource


Method create

void Standards.RDF.URIResource(string uri)

Description

Creates an URI resource with the uri as identifier.

Throws

Throws an error if another resource with the same URI already exists in the RDF domain.

  CLASS Standards.URI

Description

This class implements URI parsing and resolving of relative references to absolute form, as defined in RFC 2396


Variable scheme

string scheme

Description

Scheme component of URI


Variable authority

string authority

Description

Authority component of URI (formerly called net_loc, from RFC 2396 known as authority)


Variable path

string path

Description

Path component of URI. May be empty, but not undefined.


Variable query

string query

Description

Query component of URI. May be 0 if not present.


Variable fragment

string fragment

Description

The fragment part of URI. May be 0 if not present.


string host
string user
string password

Description

Certain classes of URI (e.g. URL) may have these defined


Variable port

int port

Description

If no port number is present in URI, but the scheme used has a default port number, this number is put here.


Variable base_uri

this_program base_uri

Description

The base URI object, if present


Method `==

int `==(mixed something)

Description

Compare this URI to something, in a canonical way.

Parameter something

Compare the URI to this


Method reparse_uri

void reparse_uri()
void reparse_uri(URI base_uri)
void reparse_uri(string base_uri)

Description

Reparse the URI with respect to a new base URI. If no base_uri was supplied, the old base_uri is thrown away. The resolving is performed according to the guidelines outlined by RFC 2396, Uniform Resource Identifiers (URI): Generic Syntax.

Parameter base_uri

Set the new base URI to this.


Method create

void Standards.URI(URI uri)
void Standards.URI(URI uri, URI base_uri)
void Standards.URI(URI uri, string base_uri)
void Standards.URI(string uri)
void Standards.URI(string uri, URI base_uri)
void Standards.URI(string uri, string base_uri)

Parameter base_uri

When supplied, will root the URI a the given location. This is needed to correctly verify relative URIs, but may be left out otherwise. If left out, and uri is a relative URI, an error is thrown.

Parameter uri

When uri is another URI object, the created URI will inherit all properties of the supplied uri except, of course, for its base_uri.


Method `->=
Method `[]=

mixed `->=(string property, mixed value)
mixed `[]=(string property, mixed value)

Description

Assign a new value to a property of URI

Parameter property

When any of the following properties are used, properties that depend on them are recalculated: user, password, host, port, authority, base_uri.

Parameter value

The value to assign to property


Method cast

string|mapping cast(string to)

Description

When cast to string, return the URI (in a canonicalized form). When cast to mapping, return a mapping with scheme, authority, user, password, host, port, path, query, fragment, raw_uri, base_uri as documented above.


Method get_path_query

string get_path_query()

Description

Returns path and query part of the URI if present.

  Module Standards.PKCS

  Module Standards.PKCS.Certificate

Description

Handle PKCS-6 and PKCS-10 certificates and certificate requests.

  Module Standards.PKCS.Signature


Method build_digestinfo

string Standards.PKCS.Signature.build_digestinfo(string msg, object hash)

Description

Construct a PKCS-1 digestinfo

Parameter msg

message to digest

Parameter hash

crypto hash object such as Crypto.sha or Crypto md5

  Module Standards.PKCS.RSA

Description

RSA operations and types as described in PKCS-1.


Method public_key

string Standards.PKCS.RSA.public_key(object rsa)

Description

Create a DER-coded RSAPublicKey structure

Parameter rsa

Crypto.rsa object

Returns

ASN1 coded RSAPublicKey structure


Method private_key

string Standards.PKCS.RSA.private_key(object rsa)

Description

Create a DER-coded RSAPrivateKey structure

Parameter rsa

Crypto.rsa object

Returns

ASN1 coded RSAPrivateKey structure


Method rsa_public_key

string Standards.PKCS.RSA.rsa_public_key(object rsa)

Deprecated

Method rsa_private_key

string Standards.PKCS.RSA.rsa_private_key(object rsa)

Deprecated

Method parse_public_key

object Standards.PKCS.RSA.parse_public_key(string key)

Description

Decode a DER-coded RSAPublicKey structure

Parameter key

RSAPublicKey provided in ASN1 encoded format

Returns

Crypto.rsa object


Method parse_private_key

object Standards.PKCS.RSA.parse_private_key(string key)

Description

Decode a DER-coded RSAPrivateKey structure

Parameter key

RSAPrivateKey provided in ASN1 encoded format

Returns

Crypto.rsa object

  Module Standards.EXIF

Description

This module implements EXIF (Exchangeable image file format for Digital Still Cameras) 2.2 parsing.


Method get_properties

mapping Standards.EXIF.get_properties(Stdio.File file)

Description

Retrieve the EXIF properties of the given file.

Parameter file

The Stdio.File object containing wanted EXIF properties.

Returns

A mapping with all found EXIF properties.

  Module Standards.ISO639_2


Method get_language

string Standards.ISO639_2.get_language(string code)

Description

Look up the language name given an ISO 639-2 code in lower case. It will first be looked up in the ISO 639-2/T table and then in ISO 639-2/B if the first lookup failed. Returns zero typed zero on failure.


Method get_language_t

string Standards.ISO639_2.get_language_t(string code)

Description

Look up the language name given an ISO 639-2/T code in lower case. Returns zero typed zero on failure.


Method get_language_b

string Standards.ISO639_2.get_language_b(string code)

Description

Look up the language name given an ISO 639-2/B code in lower case. Returns zero typed zero on failure.


Method list_languages

mapping(string:string) Standards.ISO639_2.list_languages()

Description

Return a mapping from ISO 639-2/T + ISO 639-2/B codes to language names.


Method list_languages_t

mapping(string:string) Standards.ISO639_2.list_languages_t()

Description

Return a mapping from ISO 639-2/T codes to language names.


Method list_languages_b

mapping(string:string) Standards.ISO639_2.list_languages_b()

Description

Return a mapping from ISO 639-2/B codes to language names.


Method convert_b_to_t

string Standards.ISO639_2.convert_b_to_t(string code)

Description

Converts an ISO 639-2/B code to an ISO 639-2/T code.


Method convert_t_to_b

string Standards.ISO639_2.convert_t_to_b(string code)

Description

Converts an ISO 639-2/T code to an ISO 639-2/B code.


Method verify_overlap

int(0..1) Standards.ISO639_2.verify_overlap()

Description

Returns 1 if there is an overlap between ISO 639-2/T and ISO 639-2/B symbols. Only used for debugging when updating the table.


Method map_639_1

string Standards.ISO639_2.map_639_1(string code)

Description

Look up the ISO 639-2/T code given an ISO 639-1 code in lower case.


Method map_to_639_1

string Standards.ISO639_2.map_to_639_1(string code)

Description

Look up the ISO 639-1 code given an ISO 639-2/T code in lower case.


Method list_639_1

mapping(string:string) Standards.ISO639_2.list_639_1()

Description

Return a mapping from ISO 639-1 code to ISO 639-2/T code.

  Module Standards.ID3

Description

ID3 decoder/encoder. Supports versions 1.0, 1.1, 2.2-2.4. For more info see http://www.id3.org

Note

Note that this implementation is far from complete and that interface changes might be neccessary during the implementation of the full standard.


Method synchsafe_to_int

int Standards.ID3.synchsafe_to_int(array(int) bytes)

Description

Decodes a synchsafe integer, generated according to ID3v2.4.0-structure section 6.2.

See also

int_to_synchsafe


Method int_to_synchsafe

array(int) Standards.ID3.int_to_synchsafe(int in, void|int no_bytes)

Description

Encodes a integer to a synchsafe integer according to ID3v2.4.0-structure section 6.2.

See also

synchsafe_to_int


Method resynchronise

string Standards.ID3.resynchronise(string in)

Description

Reverses the effects of unsyncronisation done according to ID3v2.4.0-structure section 6.1.

See also

unsynchronise


Method unsynchronise

string Standards.ID3.unsynchronise(string in)

Description

Unsynchronises the string according to ID3v2.4.0-structure section 6.1.

See also

resynchronise


Method decode_string

string Standards.ID3.decode_string(string in, int type)

Description

Decodes the string in from the type , according to ID3v2.4.0-structure section 4, into a wide string.

See also

encode_string


Method encode_string

array(string|int) Standards.ID3.encode_string(string in)

Description

Encodes the string in to an int-string pair, where the integer is the encoding mode, according to ID3v2.4.0-structure, and the string is the encoded string. This function tries to minimize the size of the encoded string by selecting the most apropriate encoding method.

See also

decode_string , encode_strings


Method encode_strings

array(string|int) Standards.ID3.encode_strings(array(string) in)

Description

Encodes several strings in the same way as encode_string , but encodes all the strings with the same method, selected as in encode_string . The first element in the resulting array is the selected method, while the following elements are the encoded strings.

See also

decode_string , encode_string

  CLASS Standards.ID3.Tagv2

Description

ID3 version 2 (2.2, 2.3, 2.4) Tags

  CLASS Standards.ID3.Tagv1

Description

ID3 version 1.0 or 1.1 tag

  CLASS Standards.ID3.Tag

Description

ID3 tag object

Tries to find version 2 tags in file and then version 1 tag.

Note

Version 1 tag is searched only if version 2 isn't there.

See also

Tagv2 , Tagv1


Method friendly_values

mapping friendly_values()

Description

Returns tag values in friendly manner

Note

Only version 1 equivalent of version 2 tags are returned.

  Module Tools

  CLASS Tools.PV

Description

Display a image on the screen. Requires GTK.


Inherit Window

inherit GTK.Window : Window


Typedef PVImage

typedef Standards.URI|string|Image.Image|Image.Layer|array(Image.Layer) PVImage

Description

The image types accepted. If the image is a string, it is assumed to be a filename of a image that can be loaded with Image.load. This includes URLs.


Method set_alpha_mode

void set_alpha_mode(AlphaMode m)

Description

Set the alpha combining mode. m is one of Squares , Solid , None and AlphaOnly .


Method set_alpha_colors

void set_alpha_colors(Image.Color.Color c1, Image.Color.Color|void c2)

Description

Set the colors used for the alpha combination. c2 is only used for the Squares mode,


Method get_as_image

Image.Image get_as_image(PVImage i)

Description

Return the current image as a Image object, with the alpha combining done.


Method set_image

void set_image(PVImage i)

Description

Change the image.


Method scale

void scale(float factor)

Description

Scale the image before display with the specified factor.


Method save

void save(string filename, string|void format)

Description

Write the image to a file. If no format is specified, PNG is used. The alpha combination is done on the image before it's saved.

  Module Tools.AutoDoc

  Module Tools.AutoDoc.ProcessXML


Inherit Tree

inherit Parser.XML.Tree : Tree


Inherit "module.pmod"

inherit "module.pmod"


Method extractXML

string Tools.AutoDoc.ProcessXML.extractXML(string filename, int|void pikeMode, string|void type, string|void name, array(string)|void parentModules)

Description

This function extracts documentation from a file. The parameters type , name , and parentModules are used only when pikeMode != 0 and no C-style doc comments are present.

Parameter filename

The file to extract from.

Parameter pikeMode

Non-zero if it is a Pike file. If the file contains style doc comments, C-mode is used despite pikeMode != 0.

Parameter type

"class" or "module".

Parameter name

The name of the class/module.

Parameter parentModules

The ancestors of the class/module.

Example

// To extract doc for Foo.Bar.Ippa: string xml = extractXML("lib/modules/Foo.pmod/Bar.pmod/Ippa.pike", 1, "class", "Ippa", ({ "Foo", "Bar" }));


Method moveImages

string Tools.AutoDoc.ProcessXML.moveImages(string docXMLFile, string imageSourceDir, string imageDestDir)

Description

Copy all images to canonical files in a flat directory.

Parameter docXMLFile

The contents of the XML file. The XML file is the result of extraction from a single C or Pike file, for example the result of calling extractXML .

Parameter imageSourceDir

The directory that is the base of the relative paths to images. This should be the directory of the source file that was the input to extract the XML file.

Parameter imageDestDir

The directory where the images should be copied.

Returns

The XML file contents (with decorated <image>-tags)


Method mergeTrees

void Tools.AutoDoc.ProcessXML.mergeTrees(Node dest, Node source)

Description

Puts all children of source into the tree dest , in their right place module-hierarchically. Used to merge the results of extractions of different Pike and C files.

Parameter source
Parameter dest

The nodes source and dest are <class>, <module>, <namespace> or <autodoc> nodes that are identical in the sense that they represent the same module, class or namespace. Typically they both represent <autodoc> nodes.

Note

After calling this method, any <class> or <module> nodes that have been marked with @appears or @belongs, are still in the wrong place in the tree, so handleAppears() (or postProcess() ) must be called on the whole documentation tree to relocate them once the tree has been fully merged.


Method handleAppears

void Tools.AutoDoc.ProcessXML.handleAppears(Node root)

Description

Take care of all the @appears and @belongs directives everywhere, and rearranges the nodes in the tree accordingly

Parameter root

The root (<autodoc>) node of the documentation tree.


Method postProcess

void Tools.AutoDoc.ProcessXML.postProcess(Node root)

Description

Perform the last steps on a completed documentation tree.

Parameter root

Root <autodoc> node of the completed documentation tree.

Calls handleAppears() , cleanUndocumented() and resolveRefs() in turn.

See also

handleAppears() , cleanUndocumented() , resolveRefs()

  Module Tools.Legal

  Module Tools.Legal.License


Method get_text

string Tools.Legal.License.get_text()

Description

Returns all the licenses as a string, suitable for saving as a file.

  Module Tools.Legal.Copyright

Description

Contains functions and information to store and present copyright information about Pike and it's components.


Method add

void Tools.Legal.Copyright.add(string what, array(string) holders)

Description

Adds a copyright message for the copyright holders for the component what .

Throws

An error is thrown if the copyrighted component what is already in the list of copyrights.


Method get_latest_pike

string Tools.Legal.Copyright.get_latest_pike()

Description

Return the latest copyright holder of Pike.


Method get_all

mapping(string:array(string)) Tools.Legal.Copyright.get_all()

Description

Returns a mapping containing all the stored copyrights. The mapping maps component name to an array of copyright holders.


Method get_text

string Tools.Legal.Copyright.get_text()

Description

Returns the copyrights as a string, suitable for saving as a file.

  Module Tools.Hilfe


Method format_hr_time

string Tools.Hilfe.format_hr_time(int i)

Description

Helper function that formats a time span in nanoseconds to something more human readable (ns, ms or s).

  CLASS Tools.Hilfe.Command

Description

Abstract class for Hilfe commands.


Method help

string help(string what)

Description

Returns a one line description of the command. This help should be shorter than 54 characters.


Method doc

string doc(string what, string with)

Description

A more elaborate documentation of the command. This should be less than 68 characters per line.


Method exec

void exec(Evaluator e, string line, array(string) words, array(string) tokens)

Description

The actual command callback. Messages to the user should be written out by using the safe_write method in the Evaluator object.

  CLASS Tools.Hilfe.CommandReset

Description

Variable reset command. Put ___Hilfe->commands->reset = Tools.Hilfe.CommandReset(); in your .hilferc to have this command defined when you open Hilfe.


Inherit Command

inherit Command : Command

  CLASS Tools.Hilfe.ParserState

Description

In every Hilfe object (Evaluator ) there is a ParserState object that manages the current state of the parser. Essentially tokens are entered in one end and complete expressions are outputted in the other. The parser object is accessible as ___Hilfe->state from Hilfe expressions.


Method feed

void feed(array(string) tokens)

Description

Feed more tokens into the state.


Method read

array(Expression) read()

Description

Read out completed expressions. Returns an array where every element is an expression represented as an array of tokens.


Method show_error

void show_error(function(string:int) w)

Description

Prints out any error that might have occured while push_string was executed. The error will be printed with the print function w .


Method push_string

array(string) push_string(string line)

Description

Sends the input line to Parser.Pike for tokenization, but keeps a state between each call to handle multiline /**/ comments and multiline #"" strings.


Method datap

int datap()

Description

Returns true if there is any waiting expression that can be fetched with read .


Method finishedp

int(0..1) finishedp()

Description

Are we in the middle of an expression. Used e.g. for changing the Hilfe prompt when entering multiline expressions.


Method flush

void flush()

Description

Clear the current state.


Method status

string status()

Description

Returns the current parser state. Used by "dump state".

  CLASS Tools.Hilfe.HilfeHistory

Description

In every Hilfe object (Evaluator ) there is a HilfeHistory object that manages the result history. That history object is accessible both from __ and ___Hilfe->history in Hilfe expressions.


Inherit History

inherit ADT.History : History

  CLASS Tools.Hilfe.Evaluator

Description

This class implements the actual Hilfe interpreter. It is accessible as ___Hilfe from Hilfe expressions.


Variable commands

mapping(string:Command) commands

Description

This mapping contains the available Hilfe commands, including the built in ones (dump, exit, help, new, quit), so it is possible to replace or remove them. The name of a command should be 10 characters or less.


Variable state

ParserState state

Description

Keeps the state, e.g. multiline input in process etc.


Variable variables

mapping(string:mixed) variables

Description

The locally defined variables (name:value).


Variable types

mapping(string:string) types

Description

The types of the locally defined variables (name:type).


Variable constants

mapping(string:mixed) constants

Description

The locally defined constants (name:value).


Variable functions

mapping(string:function) functions

Description

The locally defined functions (name:value).


Variable programs

mapping(string:program) programs

Description

The locally defined programs (name:value).


Variable imports

array(string) imports

Description

The current imports.


Variable inherits

array(string) inherits

Description

The current inherits.


Variable history

HilfeHistory history

Description

The current result history.


Variable write

array|object|function(string:int(0..)) write

Description

The function to use when writing to the user.


Method add_writer

void add_writer(object|function(string:int(0..)) new)

Description

Adds another output function.


Method remove_writer

void remove_writer(object|function old)

Description

Removes an output function.


Method safe_write

int safe_write(string in, mixed ... args)

Description

An output method that shouldn't crash.


Method add_input_hook

void add_input_hook(function|object new)

Description

Adds a function to the input hook, making all user data be fed into the function.

See also

remove_input_hook


Method remove_input_hook

void remove_input_hook(function|object old)

Description

Removes a function from the input hook.

See also

add_input_hook


Method create

void Tools.Hilfe.Evaluator()


Method print_version

void print_version()

Description

Displays the current version of Hilfe.


Method reset_evaluator

void reset_evaluator()

Description

Clears the current state, history and removes all locally defined variables, constants, functions and programs. Removes all imports and inherits. It does not reset the command mapping nor reevaluate the .hilferc file.


Method add_input_line

void add_input_line(string s)

Description

Input a line of text into Hilfe. It checks if s is ".", in which case it calls state->flush(). Otherwise just calls add_buffer.


Method add_buffer

void add_buffer(string s)

Description

Add buffer tokenizes the input string and determines if the new line is a Hilfe command. If not, it updates the current state with the new tokens and sends any and all complete expressions to evaluation in parse_expression .


Method parse_expression

string parse_expression(Expression expr)

Description

Parses a Pike expression. Returns 0 if everything went well, or a string with an error message otherwise.


Variable last_compiled_expr

string last_compiled_expr

Description

The last created wrapper in which an expression was evaluated.


Variable last_compile_time

int(0..) last_compile_time

Description

The last compile time;


Variable last_eval_time

int(0..) last_eval_time

Description

The last evaluation time;


Variable strict_types

int(0..1) strict_types

Description

Strict types?


Variable warnings

int(0..1) warnings

Description

Show warnings?


Variable trace_level

int trace_level

Description

The current trace level.


Variable assembler_debug_level

int assembler_debug_level

Description

The current assembler debug level. Only available if Pike is compiled with RTL debug.


Variable compiler_trace_level

int compiler_trace_level

Description

The current compiler trace level. Only available if Pike is compiled with RTL debug.


Variable debug_level

int debug_level

Description

The current debug level. Only available if Pike is compiled with RTL debug.


Method hilfe_compile

object hilfe_compile(string f, void|string new_var)

Description

Creates a wrapper and compiles the pike code f in it. If a new variable is compiled to be tested, its name should be given in new_var so that magically defined entities can be undefined and a warning printed.


Method evaluate

void evaluate(string a, int(0..1) show_result)

Description

Compiles the Pike code a and evaluates it by calling ___HilfeWrapper in the generated object. If show_result is set the result will be displayed and the result buffer updated with its value.

  CLASS Tools.Hilfe.StdinHilfe

Description

This is a wrapper containing a user interface to the Hilfe Evaluator so that it can actually be used. This wrapper uses the Stdio.Readline module to interface with the user. All input history is handled by that module, and as a consequence loading and saving .hilfe_history is handled in this class. Also .hilferc is handled by this class.


Inherit Evaluator

inherit Evaluator : Evaluator


Variable readline

Stdio.Readline readline

Description

The readline object,


Method save_history

void save_history()

Description

Saves the user input history, if possible, when called.


Method create

void Tools.Hilfe.StdinHilfe()

  CLASS Tools.Hilfe.GenericHilfe


Inherit Evaluator

inherit Evaluator : Evaluator


Method create

void Tools.Hilfe.GenericHilfe(Stdio.FILE in, Stdio.File out)

  CLASS Tools.Hilfe.GenericAsyncHilfe


Inherit Evaluator

inherit Evaluator : Evaluator


Method create

void Tools.Hilfe.GenericAsyncHilfe(Stdio.File in, Stdio.File out)

  Module Tools.Install

Description

Common routines which are useful for various install scripts based on Pike.


Method features

array(string) Tools.Install.features()


Method make_absolute_path

string Tools.Install.make_absolute_path(string path, string|void cwd)

  CLASS Tools.Install.ProgressBar


Method set_current

void set_current(int _cur)


Method set_name

void set_name(string _name)


Method set_phase

void set_phase(float _phase_base, float _phase_size)


Method update

int update(int increment)

Description

Write the current look of the progressbar to stdout.

Parameter increment

the number of increments closer to completion since last call

Returns

the length (in characters) of the line with the progressbar


Method create

void Tools.Install.ProgressBar(string name, int cur, int max, float|void phase_base, float|void phase_size)

  CLASS Tools.Install.Readline


Inherit Readline

inherit Stdio.Readline : Readline


Method trap_signal

void trap_signal(int n)


Method edit

string edit(mixed ... args)


Method edit_filename

string edit_filename(mixed ... args)


Method edit_directory

string edit_directory(mixed ... args)


Method absolute_path

string absolute_path(string path)


Method set_cwd

void set_cwd(string _cwd)

  Module Tools.sed

Description

edit commands supported:

 <firstline>,<lastline><edit command>
    ^^ numeral (17) ^^
       or relative (+17, -17)
       or a search regexp (/regexp/)
       or multiple (17/regexp//regexp/+2)
 

CommandAction
DDelete first line in space
GInsert hold space
HAppend current space to hold space
PPrint current data
a<string>Insert
c<string>Change current space
dDelete current space
hCopy current space to hold space
i<string>Print string
lPrint current space
pPrint first line in data
qQuit evaluating
s/regexp/with/xReplace
y/chars/chars/Replace chars

where line is numeral, first 'line'==0


Method `()

string|array Tools.sed.`()(string|array(string) commands, string|array(string) data, void|int suppress)

  Module Web

  Module Web.Crawler

Description

This module implements a generic web crawler.

Features:

Fully asynchronous operation (Several hundred simultaneous requests)

Supports the /robots.txt exclusion standard

Extensible

URI Queues

Allow/Deny rules

Configurable

Number of concurrent fetchers

Bits per second (bandwidth throttling)

Number of concurrent fetchers per host

Delay between fetches from the same host

Supports HTTP and HTTPS

  CLASS Web.Crawler.Stats

Description

Statistics.


Method bytes_read_callback

void bytes_read_callback(Standards.URI uri, int num_bytes_read)

Description

This callback is called when data has arrived for a presently crawled URI, but no more often than once a second.


Method close_callback

void close_callback(Standards.URI uri)

Description

This callback is called whenever the crawling of a URI is finished or fails.

  CLASS Web.Crawler.Queue

Description

A crawler queue. Does not need to be reentrant safe. The Crawler always runs in just one thread.


Method get

int|Standards.URI get()

Description

Get the next URI to index. Returns -1 if there are no URIs to index at the time of the function call, with respect to bandwidth throttling and other limits. Returns 0 if there are no more URIs to index.


Method put

void put(string|array(string)|Standards.URI|array(Standards.URI) uri)

Description

Put one or several URIs in the queue. Any URIs that were already present in the queue are silently disregarded.

  CLASS Web.Crawler.GlobRule

Description

A rule that uses glob expressions


Inherit Rule

inherit Rule : Rule


Method create

void Web.Crawler.GlobRule(string pattern)

Parameter pattern

A glob pattern that the rule will match against.

Example

GlobRule("http://pike.ida.liu.se/*.xml");

  CLASS Web.Crawler.RegexpRule

Description

A rule that uses Regexp expressions


Inherit Rule

inherit Rule : Rule


Method create

void Web.Crawler.RegexpRule(string re)

Parameter re

a string describing the Regexp expression

  CLASS Web.Crawler.RuleSet

Description

A set of rules


Method add_rule

void add_rule(Rule rule)

Description

add a rule to the ruleset


Method remove_rule

void remove_rule(Rule rule)

Description

remove a rule from the ruleset

  CLASS Web.Crawler.MySQLQueue


Inherit Queue

inherit Queue : Queue


Method create

void Web.Crawler.MySQLQueue(Stats _stats, Policy _policy, string _host, string _table, void|RuleSet _allow, void|RuleSet _deny)

  CLASS Web.Crawler.MemoryQueue

Description

Memory queue


Inherit Queue

inherit Queue : Queue


Method create

void Web.Crawler.MemoryQueue(Stats _stats, Policy _policy, RuleSet _allow, RuleSet _deny)


Method get

int|Standards.URI get()

Description

Get the next URI to index. Returns -1 if there are no URIs to index at the time of the function call, with respect to bandwidth throttling, outstanding requests and other limits. Returns 0 if there are no more URIs to index.


Method put

void put(string|array(string)|Standards.URI|array(Standards.URI) uri)

Description

Put one or several URIs in the queue. Any URIs that were already present in the queue are silently disregarded.

  CLASS Web.Crawler.ComplexQueue


Inherit Queue

inherit Queue : Queue

  CLASS Web.Crawler.Crawler


Method create

void Web.Crawler.Crawler(Queue _queue, function _page_cb, function _error_cb, function _done_cb, function _prepare_cb, string|array(string)|Standards.URI|array(Standards.URI) start_uri, mixed ... _args)

Parameter _page_cb

function called when a page is retreived. Arguments are: Standards.URI uri, mixed data, mapping headers, mixed ... args. should return an array containing additional links found within data that will be analyzed for insertion into the crawler queue (assuming they are allowed by the allow/deny rulesets.

Parameter _error_cb

function called when an error is received from a server. Arguments are: Standards.URI real_uri, int status_code, mapping headers, mixed ... args. Returns void.

Parameter _done_cb

function called when crawl is complete. Accepts mixed ... args and returns void.

Parameter _prepare_cb

argument called before a uri is retrieved. may be used to alter the request. Argument is Standards.URI uri. Returns array with element 0 of Standards.URI uri, element 1 is a header mapping for the outgoing request.

Parameter start_uri

location to start the crawl from.

Parameter _args

optional arguments sent as the last argument to the callback functions.

  Module Colors


Method rgb_to_hsv

array(int(0..255)) Colors.rgb_to_hsv(array(int(0..255)) rgb)
array(int(0..255)) Colors.rgb_to_hsv(int(0..255) r, int(0..255) g, int(0..255) b)

Description

This function returns the HSV value of the color described by the provided RGB value. It is essentially calling Image.Color.rgb(r,g,b)->hsv().

See also

Colors.hsv_to_rgb() Image.Color.Color.hsv()


Method hsv_to_rgb

array(int(0..255)) Colors.hsv_to_rgb(array(int(0..255)) hsv)
array(int(0..255)) Colors.hsv_to_rgb(int(0..255) h, int(0..255) s, int(0..255) v)

Description

This function returns the RGB value of the color described by the provided HSV value. It is essentially calling Image.Color.hsv(h,s,v)->rgb().

See also

Colors.rgb_to_hsv() Image.Color.hsv()


Method rgb_to_cmyk

array(int(0..100)) Colors.rgb_to_cmyk(array(int(0..255)) rgb)
array(int(0..100)) Colors.rgb_to_cmyk(int(0..255) r, int(0..255) g, int(0..255) b)

Description

This function returns the CMYK value of the color described by the provided RGB value. It is essentially calling Image.Color.rgb(r,g,b)->cmyk().

See also

Colors.cmyk_to_rgb() Image.Color.Color.cmyk()


Method cmyk_to_rgb

array(int(0..255)) Colors.cmyk_to_rgb(array(int(0..100)) cmyk)
array(int(0..255)) Colors.cmyk_to_rgb(int(0..100) c, int(0..100) m, int(0..100) y, int(0..100) k)

Description

This function return the RGB value of the color describe by the provided CMYK value. It is essentially calling Image.Color.cmyk(c,m,y,k)->rgb()

See also

Colors.rgb_to_cmyk() Image.Color.cmyk()


Method parse_color

array(int(0..255)) Colors.parse_color(string name)

Description

This function returns the RGB values that corresponds to the color that is provided by name to the function. It is essentially calling Image.Color.guess() , but returns the value for black if it failes.


Method color_name

string Colors.color_name(array(int(0..255)) rgb)

Description

Tries to find a name to color described by the provided RGB values. Partially an inverse function to Colors.parse_color() , although it can not find all the names that Colors.parse_color() can find RGB values for. Returns the colors rgb hex value prepended with "#" upon failure.

  Module Getopt

Description

Getopt is a group of functions which can be used to find command line options.

Command line options come in two flavors: long and short. The short ones consists of a dash followed by a character (-t), the long ones consist of two dashes followed by a string of text (--test). The short options can also be combined, which means that you can write -tda instead of -t -d -a.

Options can also require arguments, in which case they cannot be combined. To write an option with an argument you write -t argument or -targument or --test=argument.


Method find_option

string|int(0..1) Getopt.find_option(array(string) argv, array(string)|string shortform, array(string)|string|void longform, array(string)|string|void envvars, string|int(0..1)|void def, int|void throw_errors)

Description

This is a generic function to parse command line options of the type -f, --foo or --foo=bar.

Parameter argv

The first argument should be the array of strings that was sent as the second argument to your main() function.

Parameter shortform

The second is a string with the short form of your option. The short form must be only one character long. It can also be an array of strings, in which case any of the options in the array will be accepted.

Parameter longform

This is an alternative and maybe more readable way to give the same option. If you give "foo" as longform your program will accept --foo as argument. This argument can also be an array of strings, in which case any of the options in the array will be accepted.

Parameter envvars

This argument specifies an environment variable that can be used to specify the same option, to make it easier to customize program usage. It can also be an array of strings, in which case any of the mentioned variables in the array may be used.

Parameter def

This argument has two functions: It specifies if the option takes an argument or not, and it informs find_option() what to return if the option is not present. If def is given and the option does not have an argument find_option() will fail. def can be specified as UNDEFINED or left out if the option does not take an argument.

Parameter throw_errors

If throw_errors has been specified find_option() will throw errors on failure. If it has been left out, or is 0 (zero), it will instead print an error message on Stdio.stderr and exit the program with result code 1 on failure.

Returns

Returns the value the option has been set to if any.

If the option is present, but has not been set to anything 1 will be returned.

Otherwise if any of the environment variables specified in envvars has been set, that value will be returned.

If all else fails, def will be returned.

Throws

If an option that requires an argument lacks an argument and throw_errors is set an error will be thrown.

Note

find_option() modifies argv . Parsed options will be removed from argv . Elements of argv that have been removed entirely will be replaced with zeroes.

This function reads options even if they are written after the first non-option on the line.

Index 0 (zero) of argv is not scanned for options, since it is reserved for the program name.

Only the first ocurrance of an option will be parsed. To parse multiple ocurrances, call find_option() multiple times.

See also

Getopt.get_args()


Constant HAS_ARG

constant Getopt.HAS_ARG


Constant NO_ARG

constant Getopt.NO_ARG


Constant MAY_HAVE_ARG

constant Getopt.MAY_HAVE_ARG


Method find_all_options

array(array) Getopt.find_all_options(array(string) argv, array(array(array(string)|string)) options, void|int(-1..1) posix_me_harder, void|int throw_errors)

Description

This function does the job of several calls to find_option() . The main advantage of this is that it allows it to handle the POSIX_ME_HARDER environment variable better. When the either the argument posix_me_harder or the environment variable POSIX_ME_HARDER is true, no arguments will be parsed after the first non-option on the command line.

Parameter argv

The should be the array of strings that was sent as the second argument to your main() function.

Parameter options

Each element in the array options should be an array on the following form:

Array
string name

Name is a tag used to identify the option in the output.

int type

Type is one of Getopt.HAS_ARG , Getopt.NO_ARG and Getopt.MAY_HAVE_ARG and it affects how the error handling and parsing works. You should use HAS_ARG for options that require a path, a number or similar. NO_ARG should be used for options that do not need an argument, such as --version. MAY_HAVE_ARG should be used for options that may or may not need an argument.

string|array(string) aliases

This is a string or an array of string of options that will be looked for. Short and long options can be mixed, and short options can be combined into one string. Note that you must include the dashes so that find_all_options() can distinguish between long and short options. Example: ({"-tT","--test"}) This would make find_all_options look for -t, -T and --test.

void|string|array(string) env_var

This is a string or an array of strings containing names of environment variables that can be used instead of the command line option.

void|mixed default

This is the default value a MAY_HAVE_ARG option will have in the output if it was set but not assigned any value.


Only the first three elements need to be included.

Parameter posix_me_harder

Don't scan for arguments after the first non-option.

Parameter throw_errors

If throw_errors has been specified find_all_options() will throw errors on failure. If it has been left out, or is 0 (zero), it will instead print an error message on Stdio.stderr and exit the program with result code 1 on failure.

Returns

The good news is that the output from this function is a lot simpler. find_all_options() returns an array where each element is an array on this form:

Array
string name

Option identifier name from the input.

mixed value

Value given. If no value was specified, and no default has been specified, the value will be 1.


Note

find_all_options() modifies argv .

Index 0 (zero) of argv is not scanned for options, since it is reserved for the program name.

See also

Getopt.get_args() , Getopt.find_option()


Method get_args

array(string) Getopt.get_args(array(string) argv, void|int(-1..1) posix_me_harder, void|int throw_errors)

Description

This function returns the remaining command line arguments after you have run find_option() or find_all_options() to find all the options in the argument list. If there are any options left not handled by find_option() or find_all_options() this function will fail.

If throw_errors has been specified get_args() will throw errors on failure. If it has been left out, or is 0 (zero), it will instead print an error message on Stdio.stderr and exit the program with result code 1 on failure.

Returns

On success a new argv array without the parsed options is returned.

See also

Getopt.find_option() , Getopt.find_all_options()

  Module Local

Description

Local gives a local module namespace used for locally installed pike modules. Modules are searched for in the directory pike_modules which can be located in the user's home directory or profile directory, or in any of the system directories /opt/share, /usr/local/share, /opt or /usr/local/. The user's home directory is determined by examining the environment variable HOME, and if that fails the environment variable USERPROFILE. If the environment variable PIKE_LOCAL_PATH is set, the paths specified there will be searched first.

See also

Local.add_path() , Local.remove_path()


Method add_path

int(0..1) Local.add_path(string path)

Description

This function prepends path to the Local module searchpath.

Parameter path

The path to the directory to be added.

Returns

Returns 1 on success, otherwise 0.


Method remove_path

void Local.remove_path(string path)

Description

This function removes path from the Local module searchpath. If path is not in the search path, this is a noop.

Parameter path

The path to be removed.