Synchronet JavaScript Object Model Reference

Generated for Synchronet v3.12a, compiled Dec 31 2004 01:54
Includes Properties and Methods added or substantially modified in Synchronet v3.12 only.
  1. [+]  global object
  2. [+]  js object
  3. [+]  system object
  4. [+]  server object
  5. [+]  client object
  6. [+]  user object
  7. [+]  bbs object
  8. [+]  console object
  9. [+]  msg_area object
  10. [+]  file_area object
  11. [+]  xtrn_area object
  12. [+]  MsgBase class
  13. [+]  File class
  14. [+]  Queue class
  15. [+]  Socket class

global object
Top-level functions and properties (common to all servers and services)

global methods
Name Returns Usage Description
loadundefinedload([bool background or object scope,] string filename [,args]) load and execute a JavaScript module (filename), optionally specifying a target scope object (default: this) and a list of arguments to pass to the module (as argv). Returns the result (last executed statement) of the executed script or a newly created Queue object if background is true).

Background (added in v3.12):
If background is true, the loaded script runs in the background (in a child thread) but may communicate with the parent script/thread by reading from and/or writing to the parent_queue (an automatically created Queue object). The result (last executed statement) of the executed script will also be automatically written to the parent_queue which may be read later by the parent script.
backslashstringbackslash(string path) returns directory path with trailing (platform-specific) path delimeter (i.e. "slash" or "backslash")
file_cfgnamestringfile_cfgname(string path, filename) returns completed configuration filename from supplied path and filename, optionally including the local hostname (e.g. path/file.host.domain.ext or path/file.host.ext) if such a variation of the filename exists
file_mutexbooleanfile_mutex(string filename [,text]) attempts to create an exclusive (e.g. lock) file, optionally with the contents of text
netaddr_typenumbernetaddr_type(string email_address) returns the proper message net_type for the specified email_address, (e.g. NET_INTERNET for Internet e-mail or NET_NONE for local e-mail)
list_named_queuesarraylist_named_queues() returns an array of named queues (created with the Queue constructor)

global properties
Name Type Description
argcnumbernumber of arguments passed to the script
argvarrayarray of argument strings (argv.length == argc)
errnonumberlast system error number
errno_strstringdescription of last system error

js object
JavaScript execution and garbage collection control object

js methods
Name Returns Usage Description

system object
Global system-related properties and methods

system methods
Name Returns Usage Description

system properties
Name Type Description
temp_pathstring platform-specific temporary file directory

server object
Server-specifc properties

client object
Represents a TCP/IP client session

user object
Instance of User class, representing current user online

To create a new user object: var u = new User(number)

user methods
Name Returns Usage Description

bbs object
Controls the Telnet/RLogin BBS experience

bbs methods
Name Returns Usage Description

bbs properties
Name Type Description
errorlevelnumber error level returned from last executed external program
msg_thread_backnumber message thread, back message number (AKA msg_thread_orig)

console object
Controls the user's Telnet/RLogin terminal

console methods
Name Returns Usage Description
uselectnumberconsole.uselect([number, string title, string item, string ars]) user selection menu, call for each item, then with no args to display select menu

console properties
Name Type Description
input_buffer_levelnumber number of bytes currently in the input buffer (from the remote client) - READ ONLY
input_buffer_spacenumber number of bytes available in the input buffer - READ ONLY
output_buffer_levelnumber number of bytes currently in the output buffer (from the local server) - READ ONLY
output_buffer_spacenumber number of bytes available in the output buffer - READ ONLY

msg_area object
Message Areas

file_area object
File Transfer Areas

xtrn_area object
External Program Areas

MsgBase class
Class used for accessing message bases

To create a new MsgBase object: var msgbase = new MsgBase('code')
where code is a sub-board internal code, or mail for the e-mail message base

MsgBase methods
Name Returns Usage Description
get_msg_headerobjectMsgBase.get_msg_header([boolean by_offset,] number_or_id [,boolean expand_fields]) returns a specific message header, null on failure.
New in v3.12: Pass false for the expand_fields argument (default: true) if you will be re-writing the header later with put_msg_header()
save_msgbooleanMsgBase.save_msg(object header [,client] [,body_text] [,array rcpt_list]) create a new message in message base, the header object may contain the following properties:
subjectMessage subject (required)
toRecipient's name (required)
to_extRecipient's user number (for local e-mail)
to_orgRecipient's organization
to_net_typeRecipient's network type (default: 0 for local)
to_net_addrRecipient's network address
to_agentRecipient's agent type
fromSender's name (required)
from_extSender's user number
from_orgSender's organization
from_net_typeSender's network type (default: 0 for local)
from_net_addrSender's network address
from_agentSender's agent type
from_ip_addrSender's IP address (if available, for security tracking)
from_host_nameSender's host name (if available, for security tracking)
from_protocolTCP/IP protocol used by sender (if available, for security tracking)
from_portTCP/UDP port number used by sender (if available, for security tracking)
replytoReplies should be sent to this name
replyto_extReplies should be sent to this user number
replyto_orgReplies should be sent to organization
replyto_net_typeReplies should be sent to this network type
replyto_net_addrReplies should be sent to this network address
replyto_agentReplies should be sent to this agent type
idMessage's RFC-822 compliant Message-ID
reply_idMessage's RFC-822 compliant Reply-ID
reverse_pathMessage's SMTP sender address
pathMessages's NNTP path
newsgroupsMessage's NNTP newsgroups header
ftn_msgidFidoNet FTS-9 Message-ID
ftn_replyFidoNet FTS-9 Reply-ID
ftn_areaFidoNet FTS-4 echomail AREA tag
ftn_flagsFidoNet FSC-53 FLAGS
ftn_pidFidoNet FSC-46 Program Identifier
ftn_tidFidoNet FSC-46 Tosser Identifier
dateRFC-822 formatted date/time
attrAttribute bitfield
auxattrAuxillary attribute bitfield
netattrNetwork attribute bitfield
when_written_timeDate/time (in time_t format)
when_written_zoneTime zone
when_imported_timeDate/time message was imported
when_imported_zoneTime zone
thread_backMessage number that this message is a reply to
thread_nextMessage number of the next reply to the original message in this thread
thread_firstMessage number of the first reply to this message
field_list[].typeOther SMB header fields (type)
field_list[].dataOther SMB header fields (data)

New in v3.12: The optional client argument is an instance of the Client class to be used for the security log header fields (e.g. sender IP address, hostname, protocol, and port).

New in v3.12: The optional rcpt_list is an array of objects that specifies multiple recipients for a single message (e.g. bulk e-mail). Each object in the array may include the following header properties (described above):
to, to_ext, to_org, to_net_type, to_net_addr, and to_agent

MsgBase properties
Name Type Description
statusnumber return value of last SMB Library function call - READ ONLY

File class
Class used for opening, creating, reading, or writing files on the local file system

Special features include:

  1. Exclusive-access files (default) or shared files
    1. optional record-locking
    2. buffered or non-buffered I/O
  2. Support for binary files
    1. native or network byte order (endian)
    2. automatic Unix-to-Unix (UUE), yEncode (yEnc) or Base64 encoding/decoding
  3. Support for ASCII text files
    1. supports line-based I/O
      1. entire file may be read or written as an array of strings
      2. individual lines may be read or written one line at a time
    2. supports fixed-length records
      1. optional end-of-text (etx) character for automatic record padding/termination
      2. Synchronet .dat files use an etx value of 3 (Ctrl-C)
    3. supports .ini formated configuration files
      1. concept and support of root ini sections added in v3.12
    4. optional ROT13 encoding/translation
  4. Dynamically-calculated industry standard checksums (e.g. CRC-16, CRC-32, MD5)

To create a new File object: var f = new File(filename)

File methods
Name Returns Usage Description
iniSetValuebooleanFile.iniSetValue(section, key, value) set the specified key to the specified value in the specified section of a .ini file. to set a key in the root section, pass null for section.
iniSetObjectbooleanFile.iniSetObject(section, object) write all the properties of the specified object as separate key=value pairs in the specified section of a .ini file. to write an object in the root section, pass null for section.
iniSetAllObjectsarrayFile.iniSetAllObjects(object array [,name_property]) write an array of objects to a .ini file, each object in its own section named after the object's name_property (default: name)

Queue class
Class for bi-directional message queues. Used for inter-thread/module communications.

To create a new (named) Queue object: var q = new Queue(name)

Queue methods
Name Returns Usage Description
pollundefinedQueue.poll([timeout]) wait for a value on the queue for up to timeout milliseconds (default: infinite), returns true or the name (string) of the value waiting (if it has one), or false if no values are waiting
readundefinedQueue.read([name]) read a value from the queue, if name not specified, reads next value from the bottom of the queue
peekundefinedQueue.peek() peek at the value at the bottom of the queue
writebooleanQueue.write(value [,name]) write a value (optionally named) to the queue

Queue properties
Name Type Description
nameundefined name of the queue (if it has one)
data_waitingboolean true if data is waiting to be read from queue
read_levelnumber number of values in the read queue
write_levelnumber number of values in the write qeueue

Socket class
Class used for TCP/IP socket communications

To create a new Socket object: load('sockdefs.js'); var s = new Socket(type)
where type = SOCK_STREAM for TCP (default) or SOCK_DGRAM for UDP

Socket methods
Name Returns Usage Description

Totals: 12 properties, 16 methods