<<O>>  Difference Topic Kfun (r1.2 - 20 Jan 2005 - ErwinHarte)

META TOPICPARENT WebHome

Kfuns

Line: 10 to 10

acos()

Changed:
<
<
'''Definition:''' float acos(float x)
>
>
Definition
float acos(float x)

Changed:
<
<
'''Requires:''' -1 <= x <= 1
>
>
Requires
-1 <= x <= 1

Changed:
<
<
'''Returns:''' The arc cosine of x.
>
>
Returns
The arc cosine of x.

asin()

Changed:
<
<
'''Definition:''' float asin(float x)
>
>
Definition
float asin(float x)

Changed:
<
<
'''Requires:''' -1 <= x <= 1
>
>
Requires
-1 <= x <= 1

Changed:
<
<
'''Returns:''' The arc sine of x.
>
>
Returns
The arc sine of x.

atan()

Changed:
<
<
'''Definition:''' float atan(float x)
>
>
Definition
float atan(float x)

Changed:
<
<
'''Returns:''' The arc tangent of x.
>
>
Returns
The arc tangent of x.

atan2()

Changed:
<
<
'''Definition:''' float atan2(float y, float x)
>
>
Definition
float atan2(float y, float x)

Changed:
<
<
'''Returns:''' The arc tangent of y/x, determining the quadrant of the result from the signs of x and y.
>
>
Returns
The arc tangent of y/x, determining the quadrant of the result from the signs of x and y.

ceil()

Changed:
<
<
'''Definition:''' float ceil(float x)
>
>
Definition
float ceil(float x)

Changed:
<
<
'''Returns:''' x rounded to the next highest integer (that is 0.4 -> 1.0, while -0.4 -> 0.0).
>
>
Returns
x rounded to the next highest integer (that is 0.4 -> 1.0, while -0.4 -> 0.0).

cos()

Changed:
<
<
'''Definition:''' float cos(float x)
>
>
Definition
float cos(float x)

Changed:
<
<
'''Requires:''' That x not be too large (due to the way floats work, when x is greater than about 1e9, the accuracy of cos will be too low for it to be used reliably).
>
>
Requires
That x not be too large (due to the way floats work, when x is greater than about 1e9, the accuracy of cos will be too low for it to be used reliably).

Changed:
<
<
'''Returns:''' The cosine of the argument.
>
>
Returns
The cosine of the argument.

cohs()

Changed:
<
<
'''Definition:''' float cosh(float x)
>
>
Definition
float cosh(float x)

Changed:
<
<
'''Errors:''' If the calculated result is too large, an error will result.
>
>
Errors
If the calculated result is too large, an error will result.

Changed:
<
<
'''Returns:''' The hyperbolic cosine of the argument.
>
>
Returns
The hyperbolic cosine of the argument.

exp()

Changed:
<
<
'''Definition:''' float exp(float x)
>
>
Definition
float exp(float x)

Changed:
<
<
'''Returns:''' The exponential value of the given argument.
>
>
Returns
The exponential value of the given argument.

Changed:
<
<
'''Error:''' If the result is larger than a float can hold, it will generate and error.
>
>
Error
If the result is larger than a float can hold, it will generate and error.

fabs()

Changed:
<
<
'''Definition:''' float fabs(float x)
>
>
Definition
float fabs(float x)

Changed:
<
<
'''Returns:''' The absolute value of x.
>
>
Returns
The absolute value of x.

floor()

Changed:
<
<
'''Definition:''' float floor(float x)
>
>
Definition
float floor(float x)

Changed:
<
<
'''Returns:''' x rounded to the next lowest integer (that is 0.4 -> 0.0, while -0.4 -> -1.0).
>
>
Returns
x rounded to the next lowest integer (that is 0.4 -> 0.0, while -0.4 -> -1.0).

fmod()

Changed:
<
<
'''Definition:''' float fmod(float x, float y)
>
>
Definition
float fmod(float x, float y)

Changed:
<
<
'''Requires:''' y = 0.0
>
>
Requires
y = 0.0

Changed:
<
<
'''Returns:''' The value f, for which there exists an integer k such that k * y + f == x, f has the same sign of x, and the absolute value of f is less than the absolute value of y.
>
>
Returns
The value f, for which there exists an integer k such that k * y + f == x, f has the same sign of x, and the absolute value of f is less than the absolute value of y.

frexp()

Changed:
<
<
'''Definition:''' mixed *frexp(float x)
>
>
Definition
mixed *frexp(float x)

Changed:
<
<
'''Returns:''' ({y, n}), such that y*2^n = x and y = 0.0 or 0.5 <= |y| < 1.0. If x = 0.0, the result will be (0.0, 0.0).
>
>
Returns
({y, n}), such that y*2^n = x and y = 0.0 or 0.5 <= |y| < 1.0. If x = 0.0, the result will be (0.0, 0.0).

Array

allocate()

Changed:
<
<
'''Definition:''' mixed *allocate(int size)
>
>
Definition
mixed *allocate(int size)

Changed:
<
<
'''Requires:''' 0 <= size <= status()[ST_ARRAYSIZE]
>
>
Requires
0 <= size <= status()[ST_ARRAYSIZE]

Changed:
<
<
'''Returns:''' An array of the given size, with all elements initialised to nil.
>
>
Returns
An array of the given size, with all elements initialised to nil.

allocate_float()

Changed:
<
<
'''Definition:''' float *allocate_float(int size)
>
>
Definition
float *allocate_float(int size)

Changed:
<
<
'''Requires:''' 0 <= size <= status()[ST_ARRAYSIZE]
>
>
Requires
0 <= size <= status()[ST_ARRAYSIZE]

Changed:
<
<
'''Returns:''' An array of floats of the given size, with all elements initialised to 0.0.
>
>
Returns
An array of floats of the given size, with all elements initialised to 0.0.

allocate_int()

Changed:
<
<
'''Definition:''' float *allocate_int(int size)
>
>
Definition
float *allocate_int(int size)

Changed:
<
<
'''Requires:''' 0 <= size <= status()[ST_ARRAYSIZE]
>
>
Requires
0 <= size <= status()[ST_ARRAYSIZE]

Changed:
<
<
'''Returns:''' An array of ints of the given size, with all elements initialised to 0.
>
>
Returns
An array of ints of the given size, with all elements initialised to 0.

Connection

block_input()

Changed:
<
<
'''Definition:''' void block_input(int flag)
>
>
Definition
void block_input(int flag)

Changed:
<
<
'''Effect:''' Will block or unblock all input from the user associated with the current object, on a non-zero or zero flag respectively.
>
>
Effect
Will block or unblock all input from the user associated with the current object, on a non-zero or zero flag respectively.

LPC object

call_other()

Changed:
<
<
'''Definition:''' mixed call_other(mixed obj, string function, mixed args...)
>
>
Definition
mixed call_other(mixed obj, string function, mixed args...)

Changed:
<
<
'''Requires:''' obj must be either a string giving the path of a compiled object or an object.
>
>
Requires
obj must be either a string giving the path of a compiled object or an object.

Changed:
<
<
'''Effect:''' Will call the given function in obj, passing the given arguments. The function will not be called if it is private, or if it is static and obj = this_object().
>
>
Effect
Will call the given function in obj, passing the given arguments. The function will not be called if it is private, or if it is static and obj = this_object().

Changed:
<
<
'''Returns:''' The result of the called function or nil if the function doesn't exist or cannot be called with call_other().
>
>
Returns
The result of the called function or nil if the function doesn't exist or cannot be called with call_other().

Changed:
<
<
'''Note:''' The -> operator is shorthand for this function. obj->function(arg1, arg2) is equivalent to call_other(obj, "function", arg1, arg2).
>
>
Note
The -> operator is shorthand for this function. obj->function(arg1, arg2) is equivalent to call_other(obj, "function", arg1, arg2).

call_out()

Changed:
<
<
'''Definition:''' int call_out(string function, mixed delay, mixed args...)
>
>
Definition
int call_out(string function, mixed delay, mixed args...)

Changed:
<
<
'''Requires:''' Delay must either be an integer >= 0, or a float >= 0.0 and <= 60.0. Also, the number of existing callouts is less than the value of ST_COTABSIZE in the array returned by status().
>
>
Requires
Delay must either be an integer >= 0, or a float >= 0.0 and <= 60.0. Also, the number of existing callouts is less than the value of ST_COTABSIZE in the array returned by status().

Changed:
<
<
'''Effect:''' Will call the function on this object after the delay has passed, with the arguments.
>
>
Effect
Will call the function on this object after the delay has passed, with the arguments.

Changed:
<
<
'''Returns:''' The call_out handle (reference).
>
>
Returns
The call_out handle (reference).

Changed:
<
<
'''Note:''' If the maximum number of callouts is set to zero, call_out() will be ignored with no error.
>
>
Note
If the maximum number of callouts is set to zero, call_out() will be ignored with no error.

clone_object()

Changed:
<
<
'''Definition:''' object clone_object(object master)
>
>
Definition
object clone_object(object master)

Changed:
<
<
'''Requires:''' That the master object must not itself be a clone.
>
>
Requires
That the master object must not itself be a clone.

Changed:
<
<
'''Effects:''' Creates a clone of the master object with a unique name ("my_object#1234" for instance). The create(int clone) function will be called on the new object immediately, where "clone" is the number of the clone (1234 in this case).
>
>
Effects
Creates a clone of the master object with a unique name ("my_object#1234" for instance). The create(int clone) function will be called on the new object immediately, where "clone" is the number of the clone (1234 in this case).

Changed:
<
<
'''Returns:''' The new object.
>
>
Returns
The new object.

compile_object()

Changed:
<
<
'''Definition:''' object compile_object(string file)
>
>
Definition
object compile_object(string file)

Changed:
<
<
'''Requires:''' That if the object already exists, that it not be inherited by anything. file must give the full path of the file, including the extension (".c").
>
>
Requires
That if the object already exists, that it not be inherited by anything. file must give the full path of the file, including the extension (".c").

Changed:
<
<
'''Effects:''' Creates an object whose name will be the file argument. ("my_object#1234" for instance). The create(int clone) function will be called on the new object immediately, where "clone" is the number of the clone (1234 in this case). If the file already exists, then at the end of the thread all clones will be updated. Any existing variables will be kept if the new master object also has those variables and they are the same type - otherwise they will be lost.
>
>
Effects
Creates an object whose name will be the file argument. ("my_object#1234" for instance). The create(int clone) function will be called on the new object immediately, where "clone" is the number of the clone (1234 in this case). If the file already exists, then at the end of the thread all clones will be updated. Any existing variables will be kept if the new master object also has those variables and they are the same type - otherwise they will be lost.

Changed:
<
<
'''Errors:''' Compilation errors are reported to the driver, and a runtime error will occur as will if compilation fails.
>
>
Errors
Compilation errors are reported to the driver, and a runtime error will occur as will if compilation fails.

Changed:
<
<
'''Returns:''' The new object.
>
>
Returns
The new object.

destruct_object()

Changed:
<
<
'''Definition:''' void destruct_object(object obj)
>
>
Definition
void destruct_object(object obj)

Changed:
<
<
'''Effects:''' Destroys obj. If the caller is obj itself, it will be destroyed as soon as execution leaves it. If the last reference to a master object is removed, remove_program(objname) will be called on the driver.
>
>
Effects
Destroys obj. If the caller is obj itself, it will be destroyed as soon as execution leaves it. If the last reference to a master object is removed, remove_program(objname) will be called on the driver.

Changed:
<
<
'''Errors:''' If an object destructs itself, avoid doing anything after the call to destruct - in particular, call_other will prevoke an error. Basically, try to fast-track your way out of the object as quickly as possible.
>
>
Errors
If an object destructs itself, avoid doing anything after the call to destruct - in particular, call_other will provoke an error. Basically, try to fast-track your way out of the object as quickly as possible.

find_object()

Changed:
<
<
'''Definition:''' object find_object(string obj)
>
>
Definition
object find_object(string obj)

Changed:
<
<
'''Returns:''' The object whose path is obj, if there is one. Otherwise, nil.
>
>
Returns
The object whose path is obj, if there is one. Otherwise, nil.

function_object()

Changed:
<
<
'''Definition:''' string function_object(string function, object obj)
>
>
Definition
string function_object(string function, object obj)

Changed:
<
<
'''Returns:''' The name of the class which obj inherits the function from (could be the name of obj), or nil if the function doesn't exist or is not callable with call_other().
>
>
Returns
The name of the class which obj inherits the function from (could be the name of obj), or nil if the function doesn't exist or is not callable with call_other().

Runtime

call_trace()

Changed:
<
<
'''Definition:''' mixed **call_trace()
>
>
Definition
mixed **call_trace()

Changed:
<
<
'''Returns:''' An array representing the stack of the current thread. That is to say, every element of the array represents the position of the thread within a function. Each element of the array is in the following format: ({ objname, progname, function, line, extern, arg1, ..., argn }), where:
>
>
Returns
An array representing the stack of the current thread. That is to say, every element of the array represents the position of the thread within a function. Each element of the array is in the following format: ({ objname, progname, function, line, extern, arg1, ..., argn }), where:

  • objname is the name of the object it is in. (i.e. /usr/System/sys/mydaemon).
  • progname is the name of the file the current code is running in. This differs from the objname when the code being run has been inherited - it will be the inherited class.
  • function is the name of the function being called.
Line: 209 to 209

  • arg1...argn are the arguments of the function.
The offsets of the array elements are definied in /include/type.h. The last element of the call_trace is the current function.
Changed:
<
<
'''Notes:''' There are many uses for call_trace. It is used for [wiki:ThreadLocalStorage thread local storage] and debug messages in the KernelLib, for instance.
>
>
Notes
There are many uses for call_trace. It is used for thread local storage and debug messages in the KernelLib, for instance.

error()

Changed:
<
<
'''Description:''' void error(string errormessage)
>
>
Description
void error(string errormessage)

Changed:
<
<
'''Effect:''' Causes an error, which will stop execution unless caught.
>
>
Effect
Causes an error, which will stop execution unless caught.

Encryption/Decryption and Error Detection

crypt()

Changed:
<
<
'''Definition:''' string crypt(string passwd, varargs string salt)
>
>
Definition
string crypt(string passwd, varargs string salt)

Changed:
<
<
'''Returns:''' An encrypted version of the string. Without the salt, it will be basically random. They way to use this as follows - first you take the raw form of the password, and run it though crypt to get an encrypted version. Afterwards, when you want to check a string to see if it is the password, run it though crypt using the encrypted version of the password as the salt. If the result is equal to the encrypted password, then they are the same.
>
>
Returns
An encrypted version of the string. Without the salt, it will be basically random. They way to use this as follows - first you take the raw form of the password, and run it though crypt to get an encrypted version. Afterwards, when you want to check a string to see if it is the password, run it though crypt using the encrypted version of the password as the salt. If the result is equal to the encrypted password, then they are the same.

Changed:
<
<
'''Note:''' Only the first 8 characters of the passwd and the first 2 characters of the salt are significant.
>
>
Note
Only the first 8 characters of the passwd and the first 2 characters of the salt are significant.

hash_crc16()

Changed:
<
<
'''Definition:''' int hash_crc16(string str, string extra...)
>
>
Definition
int hash_crc16(string str, string extra...)

Changed:
<
<
'''Returns:''' Something. Um, perhaps someone can explain what this is, and a typical use for it?
>
>
Returns
Something. Um, perhaps someone can explain what this is, and a typical use for it?

hash_md5()

Changed:
<
<
'''Definition:''' string hash_md5(string str, string extra...)
>
>
Definition
string hash_md5(string str, string extra...)

Changed:
<
<
'''Returns:''' Something. Used for error detection?
>
>
Returns
Something. Used for error detection?

Time

ctime()

Changed:
<
<
'''Definition:''' string ctime(int time)
>
>
Definition
string ctime(int time)

Changed:
<
<
'''Returns:''' The string representation of time (as returned by time()), in the format: "Tue Aug 3 14:40:18 1993".
>
>
Returns
The string representation of time (as returned by time()), in the format: "Tue Aug 3 14:40:18 1993".

time()

Changed:
<
<
'''Definition:''' int time()
>
>
Definition
int time()

Changed:
<
<
'''Returns:''' The current time as an int.
>
>
Returns
The current time as an int.

Changed:
<
<
'''Note:''' Persumably it returns the number of seconds since time zero (which is like the beginning of 1973 or some other arbitrary date). This means that time() - old_time is the number of seconds passed since old_time.
>
>
Note
It returns the number of seconds since the unix epoch point (which is January 1, 1970, midnight, GMT/UTC). This means that time() - old_time is the number of seconds passed since old_time.

DGD System

dump_state()

Changed:
<
<
'''Definition:''' void dump_state()
>
>
Definition
void dump_state()

Changed:
<
<
'''Effect:''' Causes the system to create a state dump at the end of the current thread, to the file specified in the dgd config file. The old state dump will be copied to the same file name appended with ".old".
>
>
Effect
Causes the system to create a state dump at the end of the current thread, to the file specified in the dgd config file. The old state dump will be copied to the same file name appended with ".old".

File

editor()

Changed:
<
<
'''Definition:''' string editor(varargs string command)
>
>
Definition
string editor(varargs string command)

Changed:
<
<
'''Effect:''' Executes an editor command for the current object. This includes creating a new editor instance and associating it with the current object if necessary. This editor instance will remain active until issues a specific command to destroy it, or the associated object is destructed.
>
>
Effect
Executes an editor command for the current object. This includes creating a new editor instance and associating it with the current object if necessary. This editor instance will remain active until issues a specific command to destroy it, or the associated object is destructed.

Changed:
<
<
'''Returns:''' Editor output as a string.
>
>
Returns
Editor output as a string.

Changed:
<
<
'''Errors:''' If the number of editors is equal to the status()[ST_ETABSIZE] and a new instance needs to be created for this object, it will fail. You also cannot use the editor kfun in a user object.
>
>
Errors
If the number of editors is equal to the status()[ST_ETABSIZE] and a new instance needs to be created for this object, it will fail. You also cannot use the editor kfun in a user object.

get_dir()

Changed:
<
<
'''Definition:''' mixed **get_dir(string file)
>
>
Definition
mixed **get_dir(string file)

Changed:
<
<
'''Returns:''' Information on the given file or directory. This is returned in an array with the following format: ({ ({file names}), ({file sizes}), ({file mod times}) }). If the file in the array is a directory, it will have a file size of -2. file can be a regular expression, in which case all files matching it will be returned. If no files match, then ({ ({}),({}),({})}) will be returned. Files will be sorted by name.
>
>
Returns
Information on the given file or directory. This is returned in an array with the following format: ({ ({file names}), ({file sizes}), ({file mod times}) }). If the file in the array is a directory, it will have a file size of -2. file can be a regular expression, in which case all files matching it will be returned. If no files match, then ({ ({}),({}),({})}) will be returned. Files will be sorted by name.

Changed:
<
<
'''Errors:''' Only up to status()[ST_ARRAYSIZE] files will be returned. If there are more files, then they will not be included.
>
>
Errors
Only up to status()[ST_ARRAYSIZE] files will be returned. If there are more files, then they will not be included.

String

explode()

Changed:
<
<
'''Definition:''' string *explode(string str, string separator)
>
>
Definition
string *explode(string str, string separator)

Changed:
<
<
'''Returns:''' An array of strings, which are the parts of str seperated by the separator.
>
>
Returns
An array of strings, which are the parts of str seperated by the separator.

Changed:
<
<
'''Note:''' If a seperator is at the beginning or end of the string, there will not be a string segment exploded before it, meaning it will be lost in a implode(explode()) operation.
>
>
Note
If a seperator is at the beginning or end of the string, there will not be a string segment exploded before it, meaning it will be lost in a implode(explode()) operation.

Changed:
<
<
'''Errors:''' If the size of the resulting array is greater than status()[ST_ARRAYSIZE], an error will occur.
>
>
Errors
If the size of the resulting array is greater than status()[ST_ARRAYSIZE], an error will occur.

implode()

Changed:
<
<
'''Definition:''' string implode(string *arr, string separator)
>
>
Definition
string implode(string *arr, string separator)

Changed:
<
<
'''Returns:''' The strings in arr appended together in order, seperated by the separator string.
>
>
Returns
The strings in arr appended together in order, seperated by the separator string.

Changed:
<
<
'''Errors:''' If the resulting string would be too long, an error will result. The argument array may contain only string values.
>
>
Errors
If the resulting string would be too long, an error will result. The argument array may contain only string values.

-- ErwinHarte - 20 Jan 2005

 <<O>>  Difference Topic Kfun (r1.1 - 20 Jan 2005 - ErwinHarte)
Line: 1 to 1
Added:
>
>
META TOPICPARENT WebHome

Kfuns

These are functions provided by DGD to all objects. Some of these are masked by the KernelLib's auto object. Of course, if you are using another mudlib or are making your own then many of these may be masked.

Math

acos()

'''Definition:''' float acos(float x)

'''Requires:''' -1 <= x <= 1

'''Returns:''' The arc cosine of x.

asin()

'''Definition:''' float asin(float x)

'''Requires:''' -1 <= x <= 1

'''Returns:''' The arc sine of x.

atan()

'''Definition:''' float atan(float x)

'''Returns:''' The arc tangent of x.

atan2()

'''Definition:''' float atan2(float y, float x)

'''Returns:''' The arc tangent of y/x, determining the quadrant of the result from the signs of x and y.

ceil()

'''Definition:''' float ceil(float x)

'''Returns:''' x rounded to the next highest integer (that is 0.4 -> 1.0, while -0.4 -> 0.0).

cos()

'''Definition:''' float cos(float x)

'''Requires:''' That x not be too large (due to the way floats work, when x is greater than about 1e9, the accuracy of cos will be too low for it to be used reliably).

'''Returns:''' The cosine of the argument.

cohs()

'''Definition:''' float cosh(float x)

'''Errors:''' If the calculated result is too large, an error will result.

'''Returns:''' The hyperbolic cosine of the argument.

exp()

'''Definition:''' float exp(float x)

'''Returns:''' The exponential value of the given argument.

'''Error:''' If the result is larger than a float can hold, it will generate and error.

fabs()

'''Definition:''' float fabs(float x)

'''Returns:''' The absolute value of x.

floor()

'''Definition:''' float floor(float x)

'''Returns:''' x rounded to the next lowest integer (that is 0.4 -> 0.0, while -0.4 -> -1.0).

fmod()

'''Definition:''' float fmod(float x, float y)

'''Requires:''' y = 0.0

'''Returns:''' The value f, for which there exists an integer k such that k * y + f == x, f has the same sign of x, and the absolute value of f is less than the absolute value of y.

frexp()

'''Definition:''' mixed *frexp(float x)

'''Returns:''' ({y, n}), such that y*2^n = x and y = 0.0 or 0.5 <= |y| < 1.0. If x = 0.0, the result will be (0.0, 0.0).

Array

allocate()

'''Definition:''' mixed *allocate(int size)

'''Requires:''' 0 <= size <= status()[ST_ARRAYSIZE]

'''Returns:''' An array of the given size, with all elements initialised to nil.

allocate_float()

'''Definition:''' float *allocate_float(int size)

'''Requires:''' 0 <= size <= status()[ST_ARRAYSIZE]

'''Returns:''' An array of floats of the given size, with all elements initialised to 0.0.

allocate_int()

'''Definition:''' float *allocate_int(int size)

'''Requires:''' 0 <= size <= status()[ST_ARRAYSIZE]

'''Returns:''' An array of ints of the given size, with all elements initialised to 0.

Connection

block_input()

'''Definition:''' void block_input(int flag)

'''Effect:''' Will block or unblock all input from the user associated with the current object, on a non-zero or zero flag respectively.

LPC object

call_other()

'''Definition:''' mixed call_other(mixed obj, string function, mixed args...)

'''Requires:''' obj must be either a string giving the path of a compiled object or an object.

'''Effect:''' Will call the given function in obj, passing the given arguments. The function will not be called if it is private, or if it is static and obj = this_object().

'''Returns:''' The result of the called function or nil if the function doesn't exist or cannot be called with call_other().

'''Note:''' The -> operator is shorthand for this function. obj->function(arg1, arg2) is equivalent to call_other(obj, "function", arg1, arg2).

call_out()

'''Definition:''' int call_out(string function, mixed delay, mixed args...)

'''Requires:''' Delay must either be an integer >= 0, or a float >= 0.0 and <= 60.0. Also, the number of existing callouts is less than the value of ST_COTABSIZE in the array returned by status().

'''Effect:''' Will call the function on this object after the delay has passed, with the arguments.

'''Returns:''' The call_out handle (reference).

'''Note:''' If the maximum number of callouts is set to zero, call_out() will be ignored with no error.

clone_object()

'''Definition:''' object clone_object(object master)

'''Requires:''' That the master object must not itself be a clone.

'''Effects:''' Creates a clone of the master object with a unique name ("my_object#1234" for instance). The create(int clone) function will be called on the new object immediately, where "clone" is the number of the clone (1234 in this case).

'''Returns:''' The new object.

compile_object()

'''Definition:''' object compile_object(string file)

'''Requires:''' That if the object already exists, that it not be inherited by anything. file must give the full path of the file, including the extension (".c").

'''Effects:''' Creates an object whose name will be the file argument. ("my_object#1234" for instance). The create(int clone) function will be called on the new object immediately, where "clone" is the number of the clone (1234 in this case). If the file already exists, then at the end of the thread all clones will be updated. Any existing variables will be kept if the new master object also has those variables and they are the same type - otherwise they will be lost.

'''Errors:''' Compilation errors are reported to the driver, and a runtime error will occur as will if compilation fails.

'''Returns:''' The new object.

destruct_object()

'''Definition:''' void destruct_object(object obj)

'''Effects:''' Destroys obj. If the caller is obj itself, it will be destroyed as soon as execution leaves it. If the last reference to a master object is removed, remove_program(objname) will be called on the driver.

'''Errors:''' If an object destructs itself, avoid doing anything after the call to destruct - in particular, call_other will prevoke an error. Basically, try to fast-track your way out of the object as quickly as possible.

find_object()

'''Definition:''' object find_object(string obj)

'''Returns:''' The object whose path is obj, if there is one. Otherwise, nil.

function_object()

'''Definition:''' string function_object(string function, object obj)

'''Returns:''' The name of the class which obj inherits the function from (could be the name of obj), or nil if the function doesn't exist or is not callable with call_other().

Runtime

call_trace()

'''Definition:''' mixed **call_trace()

'''Returns:''' An array representing the stack of the current thread. That is to say, every element of the array represents the position of the thread within a function. Each element of the array is in the following format: ({ objname, progname, function, line, extern, arg1, ..., argn }), where:

  • objname is the name of the object it is in. (i.e. /usr/System/sys/mydaemon).
  • progname is the name of the file the current code is running in. This differs from the objname when the code being run has been inherited - it will be the inherited class.
  • function is the name of the function being called.
  • line is the line of the function being processed, or 0 if the function is in a compiled object.
  • extern is TRUE is the function was "call_other"ed, FALSE otherwise.
  • arg1...argn are the arguments of the function.
The offsets of the array elements are definied in /include/type.h. The last element of the call_trace is the current function.

'''Notes:''' There are many uses for call_trace. It is used for [wiki:ThreadLocalStorage thread local storage] and debug messages in the KernelLib, for instance.

error()

'''Description:''' void error(string errormessage)

'''Effect:''' Causes an error, which will stop execution unless caught.

Encryption/Decryption and Error Detection

crypt()

'''Definition:''' string crypt(string passwd, varargs string salt)

'''Returns:''' An encrypted version of the string. Without the salt, it will be basically random. They way to use this as follows - first you take the raw form of the password, and run it though crypt to get an encrypted version. Afterwards, when you want to check a string to see if it is the password, run it though crypt using the encrypted version of the password as the salt. If the result is equal to the encrypted password, then they are the same.

'''Note:''' Only the first 8 characters of the passwd and the first 2 characters of the salt are significant.

hash_crc16()

'''Definition:''' int hash_crc16(string str, string extra...)

'''Returns:''' Something. Um, perhaps someone can explain what this is, and a typical use for it?

hash_md5()

'''Definition:''' string hash_md5(string str, string extra...)

'''Returns:''' Something. Used for error detection?

Time

ctime()

'''Definition:''' string ctime(int time)

'''Returns:''' The string representation of time (as returned by time()), in the format: "Tue Aug 3 14:40:18 1993".

time()

'''Definition:''' int time()

'''Returns:''' The current time as an int.

'''Note:''' Persumably it returns the number of seconds since time zero (which is like the beginning of 1973 or some other arbitrary date). This means that time() - old_time is the number of seconds passed since old_time.

DGD System

dump_state()

'''Definition:''' void dump_state()

'''Effect:''' Causes the system to create a state dump at the end of the current thread, to the file specified in the dgd config file. The old state dump will be copied to the same file name appended with ".old".

File

editor()

'''Definition:''' string editor(varargs string command)

'''Effect:''' Executes an editor command for the current object. This includes creating a new editor instance and associating it with the current object if necessary. This editor instance will remain active until issues a specific command to destroy it, or the associated object is destructed.

'''Returns:''' Editor output as a string.

'''Errors:''' If the number of editors is equal to the status()[ST_ETABSIZE] and a new instance needs to be created for this object, it will fail. You also cannot use the editor kfun in a user object.

get_dir()

'''Definition:''' mixed **get_dir(string file)

'''Returns:''' Information on the given file or directory. This is returned in an array with the following format: ({ ({file names}), ({file sizes}), ({file mod times}) }). If the file in the array is a directory, it will have a file size of -2. file can be a regular expression, in which case all files matching it will be returned. If no files match, then ({ ({}),({}),({})}) will be returned. Files will be sorted by name.

'''Errors:''' Only up to status()[ST_ARRAYSIZE] files will be returned. If there are more files, then they will not be included.

String

explode()

'''Definition:''' string *explode(string str, string separator)

'''Returns:''' An array of strings, which are the parts of str seperated by the separator.

'''Note:''' If a seperator is at the beginning or end of the string, there will not be a string segment exploded before it, meaning it will be lost in a implode(explode()) operation.

'''Errors:''' If the size of the resulting array is greater than status()[ST_ARRAYSIZE], an error will occur.

implode()

'''Definition:''' string implode(string *arr, string separator)

'''Returns:''' The strings in arr appended together in order, seperated by the separator string.

'''Errors:''' If the resulting string would be too long, an error will result. The argument array may contain only string values.

-- ErwinHarte - 20 Jan 2005

Revision r1.1 - 20 Jan 2005 - 20:59 - ErwinHarte
Revision r1.2 - 20 Jan 2005 - 22:20 - ErwinHarte