Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commit 23a699d9 authored by rswindell's avatar rswindell

Added Synchronet version integer to each JS object, property, and method

(whenever possible), for documentation purposes (jsdocs.js).
parent a1d23e85
This diff is collapsed.
......@@ -115,15 +115,15 @@ static JSBool js_client_get(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
#define CLIENT_PROP_FLAGS JSPROP_ENUMERATE|JSPROP_READONLY
static struct JSPropertySpec js_client_properties[] = {
/* name ,tinyid ,flags, getter, setter */
{ "ip_address" ,CLIENT_PROP_ADDR ,CLIENT_PROP_FLAGS, NULL,NULL},
{ "host_name" ,CLIENT_PROP_HOST ,CLIENT_PROP_FLAGS, NULL,NULL},
{ "port" ,CLIENT_PROP_PORT ,CLIENT_PROP_FLAGS, NULL,NULL},
{ "connect_time" ,CLIENT_PROP_TIME ,CLIENT_PROP_FLAGS, NULL,NULL},
{ "protocol" ,CLIENT_PROP_PROTOCOL ,CLIENT_PROP_FLAGS, NULL,NULL},
{ "user_name" ,CLIENT_PROP_USER ,CLIENT_PROP_FLAGS, NULL,NULL},
static jsSyncPropertySpec js_client_properties[] = {
/* name ,tinyid ,flags, ver */
{ "ip_address" ,CLIENT_PROP_ADDR ,CLIENT_PROP_FLAGS, 310},
{ "host_name" ,CLIENT_PROP_HOST ,CLIENT_PROP_FLAGS, 310},
{ "port" ,CLIENT_PROP_PORT ,CLIENT_PROP_FLAGS, 310},
{ "connect_time" ,CLIENT_PROP_TIME ,CLIENT_PROP_FLAGS, 310},
{ "protocol" ,CLIENT_PROP_PROTOCOL ,CLIENT_PROP_FLAGS, 310},
{ "user_name" ,CLIENT_PROP_USER ,CLIENT_PROP_FLAGS, 310},
{0}
};
......@@ -153,12 +153,12 @@ JSObject* DLLCALL js_CreateClientObject(JSContext* cx, JSObject* parent
JS_SetPrivate(cx, obj, client); /* Store a pointer to client_t */
JS_DefineProperties(cx, obj, js_client_properties);
js_DefineSyncProperties(cx, obj, js_client_properties);
js_CreateSocketObject(cx, obj, "socket", sock);
#ifdef _DEBUG
js_DescribeObject(cx,obj,"Represents a TCP/IP client session");
js_DescribeSyncObject(cx,obj,"Represents a TCP/IP client session",310);
js_CreateArrayOfStrings(cx, obj, "_property_desc_list", client_prop_desc, JSPROP_READONLY);
#endif
......
......@@ -227,26 +227,26 @@ static JSBool js_console_set(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
#define CON_PROP_FLAGS JSPROP_ENUMERATE
static struct JSPropertySpec js_console_properties[] = {
/* name ,tinyid ,flags ,getter,setter */
{ "status" ,CON_PROP_STATUS ,CON_PROP_FLAGS ,NULL,NULL},
{ "line_counter" ,CON_PROP_LNCNTR ,CON_PROP_FLAGS ,NULL,NULL},
{ "attributes" ,CON_PROP_ATTR ,CON_PROP_FLAGS ,NULL,NULL},
{ "top_of_screen" ,CON_PROP_TOS ,CON_PROP_FLAGS ,NULL,NULL},
{ "screen_rows" ,CON_PROP_ROWS ,CON_PROP_FLAGS ,NULL,NULL},
{ "screen_columns" ,CON_PROP_COLUMNS ,CON_PROP_FLAGS ,NULL,NULL},
{ "autoterm" ,CON_PROP_AUTOTERM ,CON_PROP_FLAGS ,NULL,NULL},
{ "terminal" ,CON_PROP_TERMINAL ,CON_PROP_FLAGS ,NULL,NULL},
{ "timeout" ,CON_PROP_TIMEOUT ,CON_PROP_FLAGS ,NULL,NULL},
{ "timeleft_warning" ,CON_PROP_TIMELEFT_WARN ,CON_PROP_FLAGS ,NULL,NULL},
{ "aborted" ,CON_PROP_ABORTED ,CON_PROP_FLAGS ,NULL,NULL},
{ "abortable" ,CON_PROP_ABORTABLE ,CON_PROP_FLAGS ,NULL,NULL},
{ "telnet_mode" ,CON_PROP_TELNET_MODE ,CON_PROP_FLAGS ,NULL,NULL},
{ "wordwrap" ,CON_PROP_WORDWRAP ,JSPROP_ENUMERATE|JSPROP_READONLY ,NULL,NULL},
{ "question" ,CON_PROP_QUESTION ,CON_PROP_FLAGS ,NULL,NULL},
{ "getstr_offset" ,CON_PROP_GETSTR_OFFSET ,CON_PROP_FLAGS ,NULL,NULL},
{ "ctrlkey_passthru" ,CON_PROP_CTRLKEY_PASSTHRU ,CON_PROP_FLAGS ,NULL,NULL},
static jsSyncPropertySpec js_console_properties[] = {
/* name ,tinyid ,flags ,ver */
{ "status" ,CON_PROP_STATUS ,CON_PROP_FLAGS ,310},
{ "line_counter" ,CON_PROP_LNCNTR ,CON_PROP_FLAGS ,310},
{ "attributes" ,CON_PROP_ATTR ,CON_PROP_FLAGS ,310},
{ "top_of_screen" ,CON_PROP_TOS ,CON_PROP_FLAGS ,310},
{ "screen_rows" ,CON_PROP_ROWS ,CON_PROP_FLAGS ,310},
{ "screen_columns" ,CON_PROP_COLUMNS ,CON_PROP_FLAGS ,311},
{ "autoterm" ,CON_PROP_AUTOTERM ,CON_PROP_FLAGS ,310},
{ "terminal" ,CON_PROP_TERMINAL ,CON_PROP_FLAGS ,311},
{ "timeout" ,CON_PROP_TIMEOUT ,CON_PROP_FLAGS ,310},
{ "timeleft_warning" ,CON_PROP_TIMELEFT_WARN ,CON_PROP_FLAGS ,310},
{ "aborted" ,CON_PROP_ABORTED ,CON_PROP_FLAGS ,310},
{ "abortable" ,CON_PROP_ABORTABLE ,CON_PROP_FLAGS ,310},
{ "telnet_mode" ,CON_PROP_TELNET_MODE ,CON_PROP_FLAGS ,310},
{ "wordwrap" ,CON_PROP_WORDWRAP ,JSPROP_ENUMERATE|JSPROP_READONLY ,310},
{ "question" ,CON_PROP_QUESTION ,CON_PROP_FLAGS ,310},
{ "getstr_offset" ,CON_PROP_GETSTR_OFFSET ,CON_PROP_FLAGS ,311},
{ "ctrlkey_passthru" ,CON_PROP_CTRLKEY_PASSTHRU ,CON_PROP_FLAGS ,310},
{0}
};
......@@ -1122,147 +1122,188 @@ js_telnet_cmd(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval
}
static jsMethodSpec js_console_functions[] = {
static jsSyncMethodSpec js_console_functions[] = {
{"inkey", js_inkey, 0, JSTYPE_STRING, JSDOCSTR("[number mode] [,number timeout]")
,JSDOCSTR("get a single key with optional <i>timeout</i> in milliseconds (defaults to 0, for no wait), "
"see <tt>K_*</tt> in <tt>sbbsdefs.js</tt> for <i>mode</i> bits")
,311
},
{"getkey", js_getkey, 0, JSTYPE_STRING, JSDOCSTR("[number mode]")
,JSDOCSTR("get a single key, with wait, "
"see <tt>K_*</tt> in <tt>sbbsdefs.js</tt> for <i>mode</i> bits")
,310
},
{"getstr", js_getstr, 0, JSTYPE_STRING, JSDOCSTR("[string][,maxlen][,mode]")
,JSDOCSTR("get a text string from the user, "
"see <tt>K_*</tt> in <tt>sbbsdefs.js</tt> for <i>mode</i> bits")
,310
},
{"getnum", js_getnum, 0, JSTYPE_NUMBER, JSDOCSTR("[maxnum]")
,JSDOCSTR("get a number between 1 and <i>maxnum</i> from the user")
,310
},
{"getkeys", js_getkeys, 1, JSTYPE_NUMBER, JSDOCSTR("string keys [,maxnum]")
,JSDOCSTR("get one key from of a list of valid command <i>keys</i>, "
"or a number between 1 and <i>maxnum</i>")
,310
},
{"gettemplate", js_gettemplate, 1, JSTYPE_STRING, JSDOCSTR("format [,string] [,mode]")
,JSDOCSTR("get a string based on template")
,310
},
{"ungetstr", js_ungetstr, 1, JSTYPE_VOID, ""
,JSDOCSTR("put a string in the keyboard buffer")
,310
},
{"yesno", js_yesno, 1, JSTYPE_BOOLEAN, JSDOCSTR("string question")
,JSDOCSTR("YES/no question")
,310
},
{"noyes", js_noyes, 1, JSTYPE_BOOLEAN, JSDOCSTR("string question")
,JSDOCSTR("NO/yes question")
,310
},
{"mnemonics", js_mnemonics, 1, JSTYPE_VOID, JSDOCSTR("string text")
,JSDOCSTR("print a mnemonics string")
,310
},
{"clear", js_clear, 0, JSTYPE_VOID, ""
,JSDOCSTR("clear screen and home cursor")
,310
},
{"home", js_cursor_home, 0, JSTYPE_VOID, ""
,JSDOCSTR("send cursor to home position (x,y:1,1)")
,311
},
{"clearline", js_clearline, 0, JSTYPE_VOID, ""
,JSDOCSTR("clear current line")
,310
},
{"cleartoeol", js_cleartoeol, 0, JSTYPE_VOID, ""
,JSDOCSTR("clear to end-of-line (ANSI)")
,311
},
{"crlf", js_crlf, 0, JSTYPE_VOID, ""
,JSDOCSTR("output a carriage-return/line-feed pair (new-line)")
,310
},
{"pause", js_pause, 0, JSTYPE_VOID, ""
,JSDOCSTR("display pause prompt and wait for key hit")
,310
},
{"beep", js_beep, 1, JSTYPE_VOID, JSDOCSTR("[number count]")
,JSDOCSTR("beep for count number of times (default count is 1)")
,311
},
{"print", js_print, 1, JSTYPE_VOID, JSDOCSTR("string text")
,JSDOCSTR("display a string (supports Ctrl-A codes)")
,310
},
{"write", js_write, 1, JSTYPE_VOID, JSDOCSTR("string text")
,JSDOCSTR("display a raw string")
,310
},
{"putmsg", js_putmsg, 1, JSTYPE_VOID, JSDOCSTR("string text [,number mode]")
,JSDOCSTR("display message text (Ctrl-A codes, @-codes, pipe codes, etc), "
"see <tt>P_*</tt> in <tt>sbbsdefs.js</tt> for <i>mode</i> bits")
,310
},
{"center", js_center, 1, JSTYPE_VOID, JSDOCSTR("string text")
,JSDOCSTR("display a string centered on the screen")
,310
},
{"strlen", js_strlen, 1, JSTYPE_NUMBER, JSDOCSTR("string text")
,JSDOCSTR("returns the number of characters in text, excluding Ctrl-A codes")
,310
},
{"printfile", js_printfile, 1, JSTYPE_VOID, JSDOCSTR("string text [,number mode]")
,JSDOCSTR("print a message text file with optional mode")
,310
},
{"printtail", js_printtail, 2, JSTYPE_VOID, JSDOCSTR("string text, number lines [,number mode]")
,JSDOCSTR("print last x lines of file with optional mode")
,310
},
{"editfile", js_editfile, 1, JSTYPE_VOID, JSDOCSTR("string filename")
,JSDOCSTR("edit/create a text file using the user's preferred message editor")
,310
},
{"uselect", js_uselect, 0, JSTYPE_NUMBER, JSDOCSTR("[number, string title, string item, string ars]")
,JSDOCSTR("user selection menu, call for each item, then with no args to display select menu")
,310
},
{"saveline", js_saveline, 0, JSTYPE_VOID, ""
,JSDOCSTR("save last output line")
,310
},
{"restoreline", js_restoreline, 0, JSTYPE_VOID, ""
,JSDOCSTR("restore last output line")
,310
},
{"ansi", js_ansi, 1, JSTYPE_STRING, JSDOCSTR("number attribute")
,JSDOCSTR("returns ANSI encoding of specified attribute")
,310
},
{"ansi_save", js_pushxy, 0, JSTYPE_ALIAS },
{"ansi_pushxy", js_pushxy, 0, JSTYPE_ALIAS },
{"pushxy", js_pushxy, 0, JSTYPE_VOID, ""
,JSDOCSTR("save current cursor position (AKA ansi_save)")
,311
},
{"ansi_restore", js_popxy, 0, JSTYPE_ALIAS },
{"ansi_popxy", js_popxy, 0, JSTYPE_ALIAS },
{"popxy", js_popxy, 0, JSTYPE_VOID, ""
,JSDOCSTR("restore saved cursor position (AKA ansi_restore)")
,311
},
{"ansi_gotoxy", js_gotoxy, 1, JSTYPE_ALIAS },
{"gotoxy", js_gotoxy, 1, JSTYPE_VOID, JSDOCSTR("number x,y")
,JSDOCSTR("Move cursor to a specific screen coordinate (ANSI), "
"arguments can be separate x and y cooridinates or an object with x and y properites "
"(like that returned from <tt>console.getxy()</tt>)")
,311
},
{"ansi_up", js_cursor_up, 0, JSTYPE_ALIAS },
{"up", js_cursor_up, 0, JSTYPE_VOID, JSDOCSTR("[number rows]")
,JSDOCSTR("Move cursor up one or more rows (ANSI)")
,311
},
{"ansi_down", js_cursor_down, 0, JSTYPE_ALIAS },
{"down", js_cursor_down, 0, JSTYPE_VOID, JSDOCSTR("[number rows]")
,JSDOCSTR("Move cursor down one or more rows (ANSI)")
,311
},
{"ansi_right", js_cursor_right, 0, JSTYPE_ALIAS },
{"right", js_cursor_right, 0, JSTYPE_VOID, JSDOCSTR("[number columns]")
,JSDOCSTR("Move cursor right one or more columns (ANSI)")
,311
},
{"ansi_left", js_cursor_left, 0, JSTYPE_ALIAS },
{"left", js_cursor_left, 0, JSTYPE_VOID, JSDOCSTR("[number columns]")
,JSDOCSTR("Move cursor left one or more columns (ANSI)")
,311
},
{"ansi_getlines", js_getlines, 0, JSTYPE_ALIAS },
{"getlines", js_getlines, 0, JSTYPE_VOID, ""
,JSDOCSTR("Auto-detect the number of rows/lines on the user's terminal (ANSI)")
,311
},
{"ansi_getxy", js_getxy, 0, JSTYPE_ALIAS },
{"getxy", js_getxy, 0, JSTYPE_OBJECT, ""
,JSDOCSTR("Returns the current cursor position as an object (with x and y properties)")
,311
},
{"lock_input", js_lock_input, 1, JSTYPE_VOID, JSDOCSTR("[boolean lock]")
,JSDOCSTR("Lock the user input thread (allowing direct client socket access)")
,310
},
{"telnet_cmd", js_telnet_cmd, 2, JSTYPE_VOID, JSDOCSTR("number cmd [,number option]")
,JSDOCSTR("Send telnet command (with optional command option) to remote client")
,310
},
{"handle_ctrlkey", js_handle_ctrlkey, 1, JSTYPE_BOOLEAN, JSDOCSTR("string key [,number mode]")
,JSDOCSTR("Call internal control key handler for specified control key, returns true if handled")
,311
},
{0}
};
......@@ -1293,10 +1334,10 @@ JSObject* js_CreateConsoleObject(JSContext* cx, JSObject* parent)
,JSPROP_ENUMERATE|JSPROP_READONLY))==NULL)
return(NULL);
if(!JS_DefineProperties(cx, obj, js_console_properties))
if(!js_DefineSyncProperties(cx, obj, js_console_properties))
return(NULL);
if (!js_DefineMethods(cx, obj, js_console_functions, FALSE))
if (!js_DefineSyncMethods(cx, obj, js_console_functions, FALSE))
return(NULL);
/* Create an array of pre-defined colors */
......@@ -1318,7 +1359,7 @@ JSObject* js_CreateConsoleObject(JSContext* cx, JSObject* parent)
}
#ifdef _DEBUG
js_DescribeObject(cx,obj,"Controls the user's Telnet/RLogin terminal");
js_DescribeSyncObject(cx,obj,"Controls the user's Telnet/RLogin terminal",310);
js_CreateArrayOfStrings(cx, obj, "_property_desc_list", con_prop_desc, JSPROP_READONLY);
#endif
......
......@@ -1310,33 +1310,33 @@ static JSBool js_file_get(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
#define FILE_PROP_FLAGS JSPROP_ENUMERATE|JSPROP_READONLY
static struct JSPropertySpec js_file_properties[] = {
/* name ,tinyid ,flags, getter, setter */
{ "name" ,FILE_PROP_NAME ,FILE_PROP_FLAGS, NULL,NULL},
{ "mode" ,FILE_PROP_MODE ,FILE_PROP_FLAGS, NULL,NULL},
{ "exists" ,FILE_PROP_EXISTS ,FILE_PROP_FLAGS, NULL,NULL},
{ "is_open" ,FILE_PROP_IS_OPEN ,FILE_PROP_FLAGS, NULL,NULL},
{ "eof" ,FILE_PROP_EOF ,FILE_PROP_FLAGS, NULL,NULL},
{ "error" ,FILE_PROP_ERROR ,FILE_PROP_FLAGS, NULL,NULL},
{ "descriptor" ,FILE_PROP_DESCRIPTOR ,FILE_PROP_FLAGS, NULL,NULL},
static jsSyncPropertySpec js_file_properties[] = {
/* name ,tinyid ,flags, ver */
{ "name" ,FILE_PROP_NAME ,FILE_PROP_FLAGS, 310},
{ "mode" ,FILE_PROP_MODE ,FILE_PROP_FLAGS, 310},
{ "exists" ,FILE_PROP_EXISTS ,FILE_PROP_FLAGS, 310},
{ "is_open" ,FILE_PROP_IS_OPEN ,FILE_PROP_FLAGS, 310},
{ "eof" ,FILE_PROP_EOF ,FILE_PROP_FLAGS, 310},
{ "error" ,FILE_PROP_ERROR ,FILE_PROP_FLAGS, 310},
{ "descriptor" ,FILE_PROP_DESCRIPTOR ,FILE_PROP_FLAGS, 310},
/* writeable */
{ "etx" ,FILE_PROP_ETX ,JSPROP_ENUMERATE, NULL,NULL},
{ "debug" ,FILE_PROP_DEBUG ,JSPROP_ENUMERATE, NULL,NULL},
{ "position" ,FILE_PROP_POSITION ,JSPROP_ENUMERATE, NULL,NULL},
{ "date" ,FILE_PROP_DATE ,JSPROP_ENUMERATE, NULL,NULL},
{ "length" ,FILE_PROP_LENGTH ,JSPROP_ENUMERATE, NULL,NULL},
{ "attributes" ,FILE_PROP_ATTRIBUTES ,JSPROP_ENUMERATE, NULL,NULL},
{ "network_byte_order",FILE_PROP_NETWORK_ORDER,JSPROP_ENUMERATE, NULL,NULL},
{ "rot13" ,FILE_PROP_ROT13 ,JSPROP_ENUMERATE, NULL,NULL},
{ "uue" ,FILE_PROP_UUENCODED ,JSPROP_ENUMERATE, NULL,NULL},
{ "yenc" ,FILE_PROP_YENCODED ,JSPROP_ENUMERATE, NULL,NULL},
{ "base64" ,FILE_PROP_B64ENCODED ,JSPROP_ENUMERATE, NULL,NULL},
{ "etx" ,FILE_PROP_ETX ,JSPROP_ENUMERATE, 310},
{ "debug" ,FILE_PROP_DEBUG ,JSPROP_ENUMERATE, 310},
{ "position" ,FILE_PROP_POSITION ,JSPROP_ENUMERATE, 310},
{ "date" ,FILE_PROP_DATE ,JSPROP_ENUMERATE, 311},
{ "length" ,FILE_PROP_LENGTH ,JSPROP_ENUMERATE, 310},
{ "attributes" ,FILE_PROP_ATTRIBUTES ,JSPROP_ENUMERATE, 310},
{ "network_byte_order",FILE_PROP_NETWORK_ORDER,JSPROP_ENUMERATE, 311},
{ "rot13" ,FILE_PROP_ROT13 ,JSPROP_ENUMERATE, 311},
{ "uue" ,FILE_PROP_UUENCODED ,JSPROP_ENUMERATE, 311},
{ "yenc" ,FILE_PROP_YENCODED ,JSPROP_ENUMERATE, 311},
{ "base64" ,FILE_PROP_B64ENCODED ,JSPROP_ENUMERATE, 311},
/* dynamically calculated */
{ "crc16" ,FILE_PROP_CRC16 ,FILE_PROP_FLAGS, NULL,NULL},
{ "crc32" ,FILE_PROP_CRC32 ,FILE_PROP_FLAGS, NULL,NULL},
{ "chksum" ,FILE_PROP_CHKSUM ,FILE_PROP_FLAGS, NULL,NULL},
{ "md5_hex" ,FILE_PROP_MD5_HEX ,FILE_PROP_FLAGS, NULL,NULL},
{ "md5_base64" ,FILE_PROP_MD5_B64 ,FILE_PROP_FLAGS, NULL,NULL},
{ "crc16" ,FILE_PROP_CRC16 ,FILE_PROP_FLAGS, 311},
{ "crc32" ,FILE_PROP_CRC32 ,FILE_PROP_FLAGS, 311},
{ "chksum" ,FILE_PROP_CHKSUM ,FILE_PROP_FLAGS, 311},
{ "md5_hex" ,FILE_PROP_MD5_HEX ,FILE_PROP_FLAGS, 311},
{ "md5_base64" ,FILE_PROP_MD5_B64 ,FILE_PROP_FLAGS, 311},
{0}
};
......@@ -1370,7 +1370,7 @@ static char* file_prop_desc[] = {
#endif
static jsMethodSpec js_file_functions[] = {
static jsSyncMethodSpec js_file_functions[] = {
{"open", js_open, 1, JSTYPE_BOOLEAN, JSDOCSTR("[string mode, boolean shareable, number buflen]")
,JSDOCSTR("open file, <i>shareable</i> defaults to <i>false</i>, <i>buflen</i> defaults to 2048 bytes, "
"mode (default: <tt>w+</tt>) specifies the type of access requested for the file, as follows:<br>"
......@@ -1382,77 +1382,98 @@ static jsMethodSpec js_file_functions[] = {
"<tt>a+</tt> open for reading and appending<br>"
"<tt>b&nbsp</tt> open in binary (untranslated) mode; translations involving carriage-return and linefeed characters are suppressed (e.g. <tt>r+b</tt>)<br>"
)
,310
},
{"close", js_close, 0, JSTYPE_VOID, ""
,JSDOCSTR("close file")
,310
},
{"remove", js_delete, 0, JSTYPE_BOOLEAN, ""
,JSDOCSTR("remove the file from the disk")
,310
},
{"clearError", js_clear_error, 0, JSTYPE_ALIAS },
{"clear_error", js_clear_error, 0, JSTYPE_BOOLEAN, ""
,JSDOCSTR("clears the current error value (AKA clearError)")
,310
},
{"flush", js_flush, 0, JSTYPE_BOOLEAN, ""
,JSDOCSTR("flush/commit buffers to disk")
,310
},
{"rewind", js_rewind, 0, JSTYPE_BOOLEAN, ""
,JSDOCSTR("repositions the file pointer (<i>position</i>) to the beginning of a file "
"and clears error and end-of-file indicators")
,311
},
{"lock", js_lock, 2, JSTYPE_BOOLEAN, JSDOCSTR("[offset, length]")
,JSDOCSTR("lock file record for exclusive access (file must be opened <i>shareable</i>)")
,310
},
{"unlock", js_unlock, 2, JSTYPE_BOOLEAN, JSDOCSTR("[offset, length]")
,JSDOCSTR("unlock file record for exclusive access")
,310
},
{"read", js_read, 0, JSTYPE_STRING, JSDOCSTR("[maxlen]")
,JSDOCSTR("read a string from file (optionally unix-to-unix or base64 decoding in the process), "
"<i>maxlen</i> defaults to the current length of the file minus the current file position")
,310
},
{"readln", js_readln, 0, JSTYPE_STRING, JSDOCSTR("[maxlen]")
,JSDOCSTR("read a line-feed terminated string, <i>maxlen</i> defaults to 512 characters")
,310
},
{"readBin", js_readbin, 0, JSTYPE_NUMBER, JSDOCSTR("[bytes]")
,JSDOCSTR("read a binary integer from the file, default number of <i>bytes</i> is 4 (32-bits)")
,310
},
{"readAll", js_readall, 0, JSTYPE_ARRAY, ""
,JSDOCSTR("read all lines into an array of strings")
,310
},
{"write", js_write, 1, JSTYPE_BOOLEAN, JSDOCSTR("string text [,len]")
,JSDOCSTR("write a string to the file (optionally unix-to-unix or base64 decoding in the process)")
,310
},
{"writeln", js_writeln, 0, JSTYPE_BOOLEAN, JSDOCSTR("[string text]")
,JSDOCSTR("write a line-feed terminated string to the file")
,310
},
{"writeBin", js_writebin, 1, JSTYPE_BOOLEAN, JSDOCSTR("value [,bytes]")
,JSDOCSTR("write a binary integer to the file, default number of <i>bytes</i> is 4 (32-bits)")
,310
},
{"writeAll", js_writeall, 0, JSTYPE_BOOLEAN, JSDOCSTR("array lines")
,JSDOCSTR("write an array of strings to file")
,310
},
{"printf", js_fprintf, 0, JSTYPE_NUMBER, JSDOCSTR("string format [,args]")
,JSDOCSTR("write a formatted string to the file (ala fprintf) - "
"<small>CAUTION: for experienced C programmers ONLY</small>")
,310
},
{"iniGetSections", js_iniGetSections, 0, JSTYPE_ARRAY, JSDOCSTR("[prefix]")
,JSDOCSTR("parse all section names from a <tt>.ini</tt> file (format = '<tt>[section]</tt>') "
"and return the section names as an <i>array of strings</i>, "
"optionally, only those section names that begin with the specified <i>prefix</i>")
,311
},
{"iniGetKeys", js_iniGetKeys, 0, JSTYPE_ARRAY, JSDOCSTR("section")
,JSDOCSTR("parse all key names from the specified <i>section</i> in a <tt>.ini</tt> file "
"and return the key names as an <i>array of strings</i>")
,311
},
{"iniGetValue", js_iniGetValue, 3, JSTYPE_STRING, JSDOCSTR("section, key [,default]")
,JSDOCSTR("parse a key from a <tt>.ini</tt> file and return its value (format = '<tt>key = value</tt>'). "
"returns the specified <i>default</i> value if the key or value is missing or invalid. "
"will return a <i>bool</i>, <i>number</i>, <i>string</i>, or an <i>array of strings</i> "
"determined by the type of <i>default</i> value specified")
,311
},
{"iniGetObject", js_iniGetObject, 1, JSTYPE_OBJECT, JSDOCSTR("section")
,JSDOCSTR("parse an entire section from a .ini file "
"and return all of its keys and values as properties of an object")
,311
},
{"iniGetAllObjects",js_iniGetAllObjects,1, JSTYPE_ARRAY, JSDOCSTR("[name_property] [,prefix]")
,JSDOCSTR("parse all sections from a .ini file and return all sections and keys "
......@@ -1461,6 +1482,7 @@ static jsMethodSpec js_file_functions[] = {
"(default is <tt>\"name\"</tt>), "
"the optional <i>prefix</i> has the same use as in the <tt>iniGetSections</tt> method, "
"if a <i>prefix</i> is specified, it is removed from each section's name" )
,311
},
{0}
};
......@@ -1524,13 +1546,18 @@ js_file_constructor(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
return(JS_FALSE);
}
if(!js_DefineMethods(cx, obj, js_file_functions, FALSE)) {
dbprintf(TRUE, p, "js_DefineMethods failed");
if(!js_DefineSyncProperties(cx, obj, js_file_properties)) {
dbprintf(TRUE, p, "js_DefineSyncProperties failed");
return(JS_FALSE);
}
if(!js_DefineSyncMethods(cx, obj, js_file_functions, FALSE)) {
dbprintf(TRUE, p, "js_DefineSyncMethods failed");
return(JS_FALSE);
}
#ifdef _DEBUG
js_DescribeObject(cx,obj,"Class used for opening, creating, reading, or writing files on the local file system<p>"
js_DescribeSyncObject(cx,obj,"Class used for opening, creating, reading, or writing files on the local file system<p>"
"Special features include:</h2><ol type=disc>"
"<li>Exclusive-access files (default) or shared files<ol type=circle>"
"<li>optional record-locking"
......@@ -1554,8 +1581,9 @@ js_file_constructor(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
"</ol>"
"<li>Dynamically-calculated industry standard checksums (e.g. CRC-16, CRC-32, MD5)"
"</ol>"
,310
);
js_DescribeConstructor(cx,obj,"To create a new File object: <tt>var f = new File(filename)</tt>");
js_DescribeSyncConstructor(cx,obj,"To create a new File object: <tt>var f = new File(filename)</tt>");
js_CreateArrayOfStrings(cx, obj, "_property_desc_list", file_prop_desc, JSPROP_READONLY);
#endif
......@@ -1571,7 +1599,7 @@ JSObject* DLLCALL js_CreateFileClass(JSContext* cx, JSObject* parent)
,&js_file_class
,js_file_constructor
,1 /* number of constructor args */
,js_file_properties
,NULL /* props, set in constructor */
,NULL /* funcs, set in constructor */
,NULL,NULL);
......@@ -1589,10 +1617,10 @@ JSObject* DLLCALL js_CreateFileObject(JSContext* cx, JSObject* parent, char *nam
if(obj==NULL)
return(NULL);
if(!JS_DefineProperties(cx, obj, js_file_properties))
if(!js_DefineSyncProperties(cx, obj, js_file_properties))
return(NULL);
if (!js_DefineMethods(cx, obj, js_file_functions, FALSE))
if (!js_DefineSyncMethods(cx, obj, js_file_functions, FALSE))
return(NULL);
if((p=(private_t*)calloc(1,sizeof(private_t)))==NULL)
......
......@@ -128,7 +128,7 @@ JSObject* DLLCALL js_CreateFileAreaObject(JSContext* cx, JSObject* parent, scfg_
html_index_file="";
#ifdef _DEBUG
js_DescribeObject(cx,areaobj,"File Transfer Areas");
js_DescribeSyncObject(cx,areaobj,"File Transfer Areas",310);
#endif
/* lib_list[] */
......@@ -187,7 +187,7 @@ JSObject* DLLCALL js_CreateFileAreaObject(JSContext* cx, JSObject* parent, scfg_
return(NULL);
#ifdef _DEBUG
js_DescribeObject(cx,libobj,"File Transfer Libraries");
js_DescribeSyncObject(cx,libobj,"File Transfer Libraries",310);
#endif
/* dir_list[] */
......@@ -375,7 +375,7 @@ JSObject* DLLCALL js_CreateFileAreaObject(JSContext* cx, JSObject* parent, scfg_
#ifdef _DEBUG
js_CreateArrayOfStrings(cx, dirobj, "_property_desc_list", dir_prop_desc, JSPROP_READONLY);
js_DescribeObject(cx,dirobj,"File Transfer Directories");
js_DescribeSyncObject(cx,dirobj,"File Transfer Directories",310);
#endif
}
......@@ -385,7 +385,7 @@ JSObject* DLLCALL js_CreateFileAreaObject(JSContext* cx, JSObject* parent, scfg_
}
#ifdef _DEBUG
js_DescribeObject(cx,alldirs,"Associative array of all directories (use internal code as index)");
js_DescribeSyncObject(cx,alldirs,"Associative array of all directories (use internal code as index)",311);
JS_DefineProperty(cx,alldirs,"_dont_document",JSVAL_TRUE,NULL,NULL,JSPROP_READONLY);
#endif
......
......@@ -74,10 +74,10 @@ static JSBool js_system_get(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
#define GLOBOBJ_FLAGS JSPROP_ENUMERATE|JSPROP_READONLY
static struct JSPropertySpec js_global_properties[] = {
/* name, tinyid, flags, getter, setter */
/* name, tinyid, flags */
{ "errno", GLOB_PROP_ERRNO, GLOBOBJ_FLAGS, NULL, NULL },
{ "errno_str",GLOB_PROP_ERRNO_STR,GLOBOBJ_FLAGS, NULL, NULL },
{ "errno", GLOB_PROP_ERRNO, GLOBOBJ_FLAGS },
{ "errno_str",GLOB_PROP_ERRNO_STR,GLOBOBJ_FLAGS },
{0}
};
......@@ -2146,85 +2146,108 @@ static JSClass js_global_class = {
,JS_FinalizeStub /* finalize */
};
static jsMethodSpec js_global_functions[] = {
static jsSyncMethodSpec js_global_functions[] = {
{"exit", js_exit, 0, JSTYPE_VOID, "[number exit_code]"
,JSDOCSTR("stop script execution, "
"optionally setting the global property <tt>exit_code</tt> to the specified numeric value")
,311
},
{"load", js_load, 1, JSTYPE_BOOLEAN, JSDOCSTR("[object scope,] string filename [,args]")
,JSDOCSTR("load and execute a JavaScript module (<i>filename</i>), "
"optionally specifying a target <i>scope</i> object (default: <i>this</i>) "
"and a list of arguments to pass to the module (as <i>argv</i>), "
"returns <i>true</i> if the execution was successful")
,311
},
{"sleep", js_mswait, 0, JSTYPE_ALIAS },
{"mswait", js_mswait, 0, JSTYPE_VOID, JSDOCSTR("[number milliseconds]")
,JSDOCSTR("millisecond wait/sleep routine (AKA sleep)")
,310
},
{"yield", js_yield, 0, JSTYPE_VOID, JSDOCSTR("[bool forced]")
,JSDOCSTR("release current thread time-slice, "
"a <i>forced</i> yield will yield to all other pending tasks (lowering CPU utilization), "