AppServ | AppServRequest | CustomError | CustomException | Dir | DirEnt | Errno | Event | FD | FS | File | GD | GDFont | GDImage | PG | PGCancel | PGConn | PGDataResult | PGNotifies | PGPrintOpt | PGResult | RecvQ | SendQ | Stat | Syslog
Provided by js-appserv(8)
only. Allows the JS application to access properties and control functions in order to serve clients as it wishes. See the mmserver2(3)
manual page for internal details, on which js-appserv(8)
is based. js-appserv(8)
consists of a processes pool-based server written in C which delegates control to a JavaScript application to serve the clients.
The application should provide the following functions:
void child_init_hook(void);
- To be invoked when a new child process is created in the pool.
void child_exit_hook(void);
- To be invoked when the child process exists. Note that a process may serve multiple connections before exiting.
void child_sigalrm_hook(void);
- Invoked when a SIGALRM
signal is received. Controlled via AppServ.alarm()
.
void request_handler(req::AppServRequest);
- Function to handle the client in normal conditions.
void reject_handler(req::AppServRequest, reason::Number);
- Function to handle the client in resource exceeded conditions. Allows to provide a protocol-friendly response before the connection gets closed. reason
specifies the reason for the rejection, and may be one of AppServ.REASON_CACHE_SIZE
, AppServ.REASON_CONCURRENCY
or AppServ.REASON_RATE
.
void request_close_hook(req::AppServRequest);
- Invoked when the connection to the client is about to be closed, always.
void request_interrupt_hook(req::AppServRequest);
- If the server is configured to interrupt currently served clients when the SIGHUP
or SIGKILL
signals are received, this function is invoked.
Constructors | Static Properties | Static Methods | Properties | Methods
REASON_CACHE_SIZE | REASON_CONCURRENCY | REASON_RATE
REASON_CACHE_SIZE::Number
(ro) (Static Properties)
The address cache size for this socket was exceeded.
REASON_CONCURRENCY::Number
(ro) (Static Properties)
The address exceeded its allowed maximum number of concurrent connections.
REASON_RATE::Number
(ro) (Static Properties)
The address exceeded its allowed connections rate.
Number alarm(seconds::Number);
(Static Methods)
An alarm(3)
clone internally impemented using setitimer(3)
. Unlike alarm(3)
, always returns 0
. Useful to observe timeouts.
Number
0
.
seconds::Number
Number of seconds before timeout occurs, causing the SIGALRM
handler function to be invoked. 0
disables any timer. Otherwise resets any previously existing timer tothe new timeout.
Client request object. Holds necessary information about the client to communicate with it. Provided as an argument to the request_handler()
and reject_handler()
user functions.
Constructors | Static Properties | Static Methods | Properties | Methods
client_address_concurrency | client_address_hostname | client_address_name | client_port | client_socket | packet_data | server_socket | server_socket_address_name | server_socket_family | server_socket_port | server_socket_type
client_address_concurrency::Number
(ro) (Properties)
Number of simultaneous current connections for this address.
client_address_hostname::String
(ro) (Properties)
Hostname of the client's address.
client_address_name::String
(ro) (Properties)
Address of the client.
client_port::Number
(ro) (Properties)
IP port of the client.
client_socket::Number
(ro) (Properties)
Unix file descriptor number of the client socket. This is used to serve the client.
packet_data::String
(ro) (Properties)
If serving UDP clients, the first received packet.
server_socket::Number
(ro) (Properties)
Unix file descriptor number of the server listening socket. Usually only useful to bind UDP sockets.
server_socket_address_name::String
(ro) (Properties)
Address the server socket was bound to.
server_socket_family::Number
(ro) (Properties)
server_socket_port::Number
(ro) (Properties)
IP port of the server socket the client was accepted on.
server_socket_type::Number
(ro) (Properties)
Extends Error
This class extends the system Error
class as should normally be done. However, when doing so the stack backtrace becomes unavailable, possibly as the result of a SpiderMonkey bug. Thus, it is recommended to use CustomException
instead.
Constructors | Static Properties | Static Methods | Properties | Methods
void CustomError(name::String, errnum::Number, message::String);
(Constructors)
This constructor may be invoked as a method or as a constructor, that is, using the new
keyword or without it.
name::String
The name or type of error. Examples are SyntaxError
and TypeError
.
errnum::Number
Numeric error code to associate to this error object. This can reflect the internal errno
error, but does not have to. It is recommended to use codes from errno(2)
when possible.
message::String
Associated message to describe the error and provide more details. Has no formal structure. The backtrace often provides enough context information, yet this may convey useful other details. May optionally map to the corresponding text of an errno
code.
This actually creates an Error
system object and then adds custom properties to this. This allows the stack backtrace to be available which is most useful.
Unlike CustomError
, this does not extend the system Error
class. This means that the code cannot use instanceof
to determine the type of exception/error. Instead, conditionals such as x.name == 'IOException'
may be used instead.
The C classes invoke customexception_throw()
to generate the same object and also preserve the stack backtrace.
Constructors | Static Properties | Static Methods | Properties | Methods
void CustomException(name::String, errnum::Number, message::String);
(Constructors)
This constructor may be invoked as a method or as a constructor, that is, using the new
keyword or without it.
name::String
The name or type of error. Examples are SyntaxError
and TypeError
, or IOException
.
errnum::Number
Numeric error code to associate to this error object. This can reflect the internal errno
error, but does not have to. It is recommended to use codes from errno(2)
when possible.
message::String
Associated message to describe the error and provide more details. Has no formal structure. The backtrace often provides enough context information, yet this may convey useful other details. May optionally map to the corresponding text of an errno
code.
A C opendir(3)
and friends wrapper class. Allows to iterate over directory entries. Also see FD.fstat()
. Note that deleting a Dir
object also closes the directory.
Constructors | Static Properties | Static Methods | Properties | Methods
void Dir(path::String);
(Constructors)
Creates a Dir
object opening a directory.
path::String
Path to directory to be opened.
IOException
Object holds details.
SecurityException
Path was not allowed access to.
DT_BLK | DT_CHR | DT_DIR | DT_FIFO | DT_LNK | DT_REG | DT_SOCK | DT_UNKNOWN
DT_BLK::Number
(ro) (Static Properties)
File is a block device.
DT_CHR::Number
(ro) (Static Properties)
File is a character device.
DT_DIR::Number
(ro) (Static Properties)
File is a directory.
DT_FIFO::Number
(ro) (Static Properties)
File is a FIFO.
DT_LNK::Number
(ro) (Static Properties)
File is a link.
DT_REG::Number
(ro) (Static Properties)
File is a regular file.
DT_SOCK::Number
(ro) (Static Properties)
File is a unix socket.
DT_UNKNOWN::Number
(ro) (Static Properties)
Unknown file type.
close | read | rewind | seek | tell
Number close(void);
(Methods)
Closes the stream.
Number
status 0
on success, or an errno
value on failure (see the Errno
class for details).
DirEnt|null read(void);
(Methods)
Iterating over directory entries, returns the next entry.
DirEnt|null
Returns a DirEnt
object which holds information about the file. null
is returned after the last entry has been retreived.
void rewind(void);
(Methods)
Rewinds/resets stream position to the initial location.
void seek(loc::Number);
(Methods)
Return to a previous location.
loc::Number
Location to return to. Note that only previous positions returned by former calls to Dir.tell()
are valid to pass to this method.
Number tell(void);
(Methods)
Reports current position in stream.
Number
Current position, for use with Dir.seek()
.
Represents a directory entry. Not an actual class per say, but an untyped object, holding properties. These are returned by Dir.read()
.
Constructors | Static Properties | Static Methods | Properties | Methods
fileno::Number
(ro) (Properties)
File number of entry.
name::String
(ro) (Properties)
File name.
type::Number
(ro) (Properties)
File type.
This class allows to work with C and unix native error codes. It simply consists of a wrapper around strerror(3)
and errno(2)
.
Constructors | Static Properties | Static Methods | Properties | Methods
EACCES | EADDRINUSE | EADDRNOTAVAIL | EAFNOSUPPORT | EAGAIN | EALREADY | EBADF | EBADMSG | EBUSY | ECANCELED | ECONNABORTED | ECONNREFUSED | ECONNRESET | EDESTADDRREQ | EDQUOT | EEXIST | EFBIG | EFTYPE | EHOSTDOWN | EHOSTUNREACH | EINPROGRESS | EINTR | EINVAL | EIO | EISCONN | EISDIR | ELOOP | EMFILE | EMLINK | EMSGSIZE | ENAMETOOLONG | ENETDOWN | ENETRESET | ENETUNREACH | ENFILE | ENOBUFS | ENODATA | ENODEV | ENOENT | ENOLCK | ENOMSG | ENOSPC | ENOSYS | ENOTBLK | ENOTCONN | ENOTDIR | ENOTEMPTY | ENOTSOCK | ENOTSUP | ENOTTY | ENXIO | EOPNOTSUPP | EPERM | EPFNOSUPPORT | EPIPE | EPROTONOSUPPORT | EPROTOTYPE | EROFS | ESHUTDOWN | ESPIPE | ESTALE | ETIME | ETIMEDOUT | ETXTBSY | EXDEV
EACCES::Number
(ro) (Static Properties)
EADDRINUSE::Number
(ro) (Static Properties)
EADDRNOTAVAIL::Number
(ro) (Static Properties)
EAFNOSUPPORT::Number
(ro) (Static Properties)
EAGAIN::Number
(ro) (Static Properties)
EALREADY::Number
(ro) (Static Properties)
EBADF::Number
(ro) (Static Properties)
EBADMSG::Number
(ro) (Static Properties)
EBUSY::Number
(ro) (Static Properties)
ECANCELED::Number
(ro) (Static Properties)
ECONNABORTED::Number
(ro) (Static Properties)
ECONNREFUSED::Number
(ro) (Static Properties)
ECONNRESET::Number
(ro) (Static Properties)
EDESTADDRREQ::Number
(ro) (Static Properties)
EDQUOT::Number
(ro) (Static Properties)
EEXIST::Number
(ro) (Static Properties)
EFBIG::Number
(ro) (Static Properties)
EFTYPE::Number
(ro) (Static Properties)
EHOSTDOWN::Number
(ro) (Static Properties)
EHOSTUNREACH::Number
(ro) (Static Properties)
EINPROGRESS::Number
(ro) (Static Properties)
EINTR::Number
(ro) (Static Properties)
EINVAL::Number
(ro) (Static Properties)
EIO::Number
(ro) (Static Properties)
EISCONN::Number
(ro) (Static Properties)
EISDIR::Number
(ro) (Static Properties)
ELOOP::Number
(ro) (Static Properties)
EMFILE::Number
(ro) (Static Properties)
EMLINK::Number
(ro) (Static Properties)
EMSGSIZE::Number
(ro) (Static Properties)
ENAMETOOLONG::Number
(ro) (Static Properties)
ENETDOWN::Number
(ro) (Static Properties)
ENETRESET::Number
(ro) (Static Properties)
ENETUNREACH::Number
(ro) (Static Properties)
ENFILE::Number
(ro) (Static Properties)
ENOBUFS::Number
(ro) (Static Properties)
ENODATA::Number
(ro) (Static Properties)
ENODEV::Number
(ro) (Static Properties)
ENOENT::Number
(ro) (Static Properties)
ENOLCK::Number
(ro) (Static Properties)
ENOMSG::Number
(ro) (Static Properties)
ENOSPC::Number
(ro) (Static Properties)
ENOSYS::Number
(ro) (Static Properties)
ENOTBLK::Number
(ro) (Static Properties)
ENOTCONN::Number
(ro) (Static Properties)
ENOTDIR::Number
(ro) (Static Properties)
ENOTEMPTY::Number
(ro) (Static Properties)
ENOTSOCK::Number
(ro) (Static Properties)
ENOTSUP::Number
(ro) (Static Properties)
ENOTTY::Number
(ro) (Static Properties)
ENXIO::Number
(ro) (Static Properties)
EOPNOTSUPP::Number
(ro) (Static Properties)
EPERM::Number
(ro) (Static Properties)
EPFNOSUPPORT::Number
(ro) (Static Properties)
EPIPE::Number
(ro) (Static Properties)
EPROTONOSUPPORT::Number
(ro) (Static Properties)
EPROTOTYPE::Number
(ro) (Static Properties)
EROFS::Number
(ro) (Static Properties)
ESHUTDOWN::Number
(ro) (Static Properties)
ESPIPE::Number
(ro) (Static Properties)
ESTALE::Number
(ro) (Static Properties)
ETIME::Number
(ro) (Static Properties)
ETIMEDOUT::Number
(ro) (Static Properties)
ETXTBSY::Number
(ro) (Static Properties)
EXDEV::Number
(ro) (Static Properties)
String strerror(code::Number);
(Static Methods)
Returns string describing an error code.
String
String describing the supplied code.
code::Number
Error code to translate.
This class allows to use efficient OS primitives for events, through the event(3)
library. For instance, on BSD systems, kqueue(2)
is used internally, which not only is a system which exceeds dramatically the performance of poll(2)
, but also supports a number of event types other than for file descriptor polling.
Currently, only file descriptor polling is supported in JS using FD
objects. There are however plans to eventually support signal and timer events as well.
This is a callback driven system. This means that you must register descriptors and events you're interested in as well as which JS functions to execute, and call a dispatch function. Very much like unix signal handling. This allows the main processing loop to remain in C.
Constructors | Static Properties | Static Methods | Properties | Methods
EVLOOP_NONBLOCK | EVLOOP_ONCE | EV_PERSIST | EV_READ | EV_SIGNAL | EV_TIMEOUT | EV_WRITE | SIGABRT | SIGALRM | SIGBUS | SIGCHLD | SIGCONT | SIGEMT | SIGFPE | SIGHUP | SIGILL | SIGINFO | SIGINT | SIGIO | SIGKILL | SIGPIPE | SIGPROF | SIGPWR | SIGQUIT | SIGSEGV | SIGSTOP | SIGSYS | SIGTERM | SIGTRAP | SIGTSTP | SIGTTIN | SIGTTOU | SIGURG | SIGUSR1 | SIGUSR2 | SIGVTALRM | SIGWINCH | SIGXCPU | SIGXFSZ
EVLOOP_NONBLOCK::Number
(ro) (Static Properties)
EVLOOP_ONCE::Number
(ro) (Static Properties)
EV_PERSIST::Number
(ro) (Static Properties)
EV_READ::Number
(ro) (Static Properties)
EV_SIGNAL::Number
(ro) (Static Properties)
EV_TIMEOUT::Number
(ro) (Static Properties)
EV_WRITE::Number
(ro) (Static Properties)
SIGABRT::Number
(ro) (Static Properties)
SIGALRM::Number
(ro) (Static Properties)
SIGBUS::Number
(ro) (Static Properties)
SIGCHLD::Number
(ro) (Static Properties)
SIGCONT::Number
(ro) (Static Properties)
SIGEMT::Number
(ro) (Static Properties)
SIGFPE::Number
(ro) (Static Properties)
SIGHUP::Number
(ro) (Static Properties)
SIGILL::Number
(ro) (Static Properties)
SIGINFO::Number
(ro) (Static Properties)
SIGINT::Number
(ro) (Static Properties)
SIGIO::Number
(ro) (Static Properties)
SIGKILL::Number
(ro) (Static Properties)
SIGPIPE::Number
(ro) (Static Properties)
SIGPROF::Number
(ro) (Static Properties)
SIGPWR::Number
(ro) (Static Properties)
SIGQUIT::Number
(ro) (Static Properties)
SIGSEGV::Number
(ro) (Static Properties)
SIGSTOP::Number
(ro) (Static Properties)
SIGSYS::Number
(ro) (Static Properties)
SIGTERM::Number
(ro) (Static Properties)
SIGTRAP::Number
(ro) (Static Properties)
SIGTSTP::Number
(ro) (Static Properties)
SIGTTIN::Number
(ro) (Static Properties)
SIGTTOU::Number
(ro) (Static Properties)
SIGURG::Number
(ro) (Static Properties)
SIGUSR1::Number
(ro) (Static Properties)
SIGUSR2::Number
(ro) (Static Properties)
SIGVTALRM::Number
(ro) (Static Properties)
SIGWINCH::Number
(ro) (Static Properties)
SIGXCPU::Number
(ro) (Static Properties)
SIGXFSZ::Number
(ro) (Static Properties)
addFD | delFD | dispatch | initializedFD | loop | loopExit | onceFD | pendingFD | setFD
Number addFD(fd::FD, timeout::Number|null);
(Static Methods)
Permits to activate an FD
object which parameters were previously set using Event.setFD()
, adding it into the polling set. Note that unless the event were configured with the EV_PERSIST
flag, descriptors should be added again to the set after an event occurs (this can be done in the callback function).
Number
0
on success or an errno
code on error.
fd::FD
Descriptor to add to the set.
timeout::Number|null
Timeout in milliseconds after which an EV_TIMEOUT
event should be generated, or null
to wait indefinitely.
Number delFD(fd::FD);
(Static Methods)
Removes a descriptor from the polling set. This is usually used when they are added using the EV_PERSIST
flag. Otherwise descriptors are removed from the set automatically as an event occurs.
Number
0
on success or an errno
code on error.
fd::FD
Descriptor to remove from the polling set.
Number dispatch(void);
(Static Methods)
Invokes the event poller and dispatcher. This method never returns unless an error occurs. Descriptors and/or other type of objects and events must previously have been configured and added.
Number
An errno
error code.
Boolean initializedFD(fd::FD);
(Static Methods)
Tells weither or not the specified descriptor was configured using Event.setFD()
.
Boolean
true
or false
.
fd::FD
Event to verify initialization status of.
Number loop(flags::Number);
(Static Methods)
Similar to Event.dispatch()
, although this function returns after events are dispatched.
Number
flags::Number
Supported flags consist of Event.EVLOOP_ONCE
, causing only a single event to be dispatched before returning, and Event.EVLOOP_NONBLOCK
which permits the function to return even if no events could immediately be dispatched. These may be OR
ed, or 0
may be supplied.
void loopExit(timeout::Number);
(Static Methods)
Very similar to Event.loop()
except that a timeout is supplied specifying when to return.
timeout::Number
Timeout in milliseconds.
Number onceFD(fd::FD, event::Number, function::Function, udata::Object|null, timeout::Number|null);
(Static Methods)
This is equivalent to configuring a descriptor using FD.setFD()
and then adding it using FD.addFD()
without the EV_PERSIST
flag. Supported at EV_TIMEOUT
, EV_READ
and EV_WRITE
. The callback function is scheduled to be executed only once.
Number
0
on success, or an errno
code on error.
fd::FD
Descriptor to poll events for.
event::Number
OR
ed event types which are interesting.
function::Function
Callback function to be invoked when the event occurs. See Event.setFD()
for the function signature.
udata::Object|null
Optional user data object reference to be passed to the callback for state persistency. null
may be used if none is wanted.
timeout::Number|null
Timeout in milliseconds to poll for, or null
to wait indefinitely.
Boolean pendingFD(fd::FD, event::Number, timeout::Object|null);
(Static Methods)
Verifies if an event specified for a descriptor is pending to run.
Boolean
true
if the event is pending, false
otherwise.
fd::FD
Descriptor to verify for pending events.
event::Number
Event(s) to verify pending status of.
timeout::Object|null
If not null
and Event.EV_TIMEOUT
is as parts of event
, two properties will be added to the supplied object, namely: tv_sec::Number
, in seconds and tv_usec::Number
in microseconds, telling in how long the event is set to expire.
void setFD(fd::FD, event::Number, function::Function, udata::Object|null);
(Static Methods)
Allows to specify which type of events are to be watched for, as well as the callback function which should serve them, for an FD
object. Note that it is possible to reconfigure a descriptor differently as needed.
fd::FD
File descriptor object to work on.
event::Number
Events we're interested in catching for the descriptor.
function::Function
Function to be invoked when an event occurs. The function signature is as follows:
Boolean function(fd::FD, event::Number, udata::Object);
Where fd
consists of the descriptor for which there was an event, event
consists of an OR
ed mask of received events for the descriptor, and udata
is the object reference passed to the Event.setFD()
method (which may be null
).
udata::Object|null
User data object reference which may be passed to the function if wanted to keep a persistent state. This is provided for usefullness and compatibility with the C interface, although in JavaScript the wanted properties for state may simply be added to the FD
object and accessed there in callback functions. You may pass null
to this argument.
Implements support for unix file descriptor objects. Blocking, non-blocking modes are provided, as well as libevent(3)
and poll(2)
support. IPv4 sockets also are along with socket options. XXX
Other address families should eventually be supported, although js-appserv(8) supports them already.
The static properties of this class map to the C equivalent integers. These are required for a number of functions which are basically C function mappings as well, other than having been reorganized to be more OO friendly.
Constructors | Static Properties | Static Methods | Properties | Methods
void FD(void);
(Constructors)
Creates an FD
object, but does not initialize it as a socket or file descriptor yet.
AF_INET | F_GETFL | F_SETFL | LOCK_EX | LOCK_NB | LOCK_SH | LOCK_UN | O_CREAT | O_NONBLOCK | O_RDONLY | O_RDWR | O_TRUNC | O_WRONLY | POLLERR | POLLHUP | POLLIN | POLLNVAL | POLLOUT | POLLPRI | POLLRDBAND | POLLRDNORM | POLLWRBAND | POLLWRNORM | SEEK_CUR | SEEK_END | SEEK_SET | SF_APPEND | SF_ARCHIVED | SF_IMMUTABLE | SHUT_RD | SHUT_RDRW | SHUT_RW | SOCK_DGRAM | SOCK_STREAM | SO_BROADCAST | SO_DONTROUTE | SO_ERROR | SO_KEEPALIVE | SO_LINGER | SO_OOBINLINE | SO_RCVBUF | SO_RCVLOWAT | SO_RCVTIMEO | SO_REUSEADDR | SO_REUSEPORT | SO_SNDBUF | SO_SNDLOWAT | SO_SNDTIMEO | SO_TYPE | STDERR_FILENO | STDIN_FILENO | STDOUT_FILENO | S_IFBLK | S_IFCHR | S_IFDIR | S_IFIFO | S_IFLNK | S_IFMT | S_IFREG | S_IFSOCK | S_IFWHT | S_IRGRP | S_IROTH | S_IRUSR | S_IRWXG | S_IRWXO | S_IRWXU | S_ISGID | S_ISUID | S_ISVTX | S_IWOTH | S_IWUSR | S_IXGRP | S_IXOTH | S_IXUSR | TCP_NODELAY | UF_APPEND | UF_IMMUTABLE | UF_NODUMP | UF_OPAQUE
AF_INET::Number
(ro) (Static Properties)
F_GETFL::Number
(ro) (Static Properties)
F_SETFL::Number
(ro) (Static Properties)
LOCK_EX::Number
(ro) (Static Properties)
LOCK_NB::Number
(ro) (Static Properties)
LOCK_SH::Number
(ro) (Static Properties)
LOCK_UN::Number
(ro) (Static Properties)
O_CREAT::Number
(ro) (Static Properties)
O_NONBLOCK::Number
(ro) (Static Properties)
O_RDONLY::Number
(ro) (Static Properties)
O_RDWR::Number
(ro) (Static Properties)
O_TRUNC::Number
(ro) (Static Properties)
O_WRONLY::Number
(ro) (Static Properties)
POLLERR::Number
(ro) (Static Properties)
POLLHUP::Number
(ro) (Static Properties)
POLLIN::Number
(ro) (Static Properties)
POLLNVAL::Number
(ro) (Static Properties)
POLLOUT::Number
(ro) (Static Properties)
POLLPRI::Number
(ro) (Static Properties)
POLLRDBAND::Number
(ro) (Static Properties)
POLLRDNORM::Number
(ro) (Static Properties)
POLLWRBAND::Number
(ro) (Static Properties)
POLLWRNORM::Number
(ro) (Static Properties)
SEEK_CUR::Number
(ro) (Static Properties)
SEEK_END::Number
(ro) (Static Properties)
SEEK_SET::Number
(ro) (Static Properties)
SF_APPEND::Number
(ro) (Static Properties)
SF_ARCHIVED::Number
(ro) (Static Properties)
SF_IMMUTABLE::Number
(ro) (Static Properties)
SHUT_RD::Number
(ro) (Static Properties)
SHUT_RDRW::Number
(ro) (Static Properties)
SHUT_RW::Number
(ro) (Static Properties)
SOCK_DGRAM::Number
(ro) (Static Properties)
SOCK_STREAM::Number
(ro) (Static Properties)
SO_BROADCAST::Number
(ro) (Static Properties)
SO_DONTROUTE::Number
(ro) (Static Properties)
SO_ERROR::Number
(ro) (Static Properties)
SO_KEEPALIVE::Number
(ro) (Static Properties)
SO_LINGER::Number
(ro) (Static Properties)
SO_OOBINLINE::Number
(ro) (Static Properties)
SO_RCVBUF::Number
(ro) (Static Properties)
SO_RCVLOWAT::Number
(ro) (Static Properties)
SO_RCVTIMEO::Number
(ro) (Static Properties)
SO_REUSEADDR::Number
(ro) (Static Properties)
SO_REUSEPORT::Number
(ro) (Static Properties)
SO_SNDBUF::Number
(ro) (Static Properties)
SO_SNDLOWAT::Number
(ro) (Static Properties)
SO_SNDTIMEO::Number
(ro) (Static Properties)
SO_TYPE::Number
(ro) (Static Properties)
STDERR_FILENO::Number
(ro) (Static Properties)
STDIN_FILENO::Number
(ro) (Static Properties)
STDOUT_FILENO::Number
(ro) (Static Properties)
S_IFBLK::Number
(ro) (Static Properties)
S_IFCHR::Number
(ro) (Static Properties)
S_IFDIR::Number
(ro) (Static Properties)
S_IFIFO::Number
(ro) (Static Properties)
S_IFLNK::Number
(ro) (Static Properties)
S_IFMT::Number
(ro) (Static Properties)
S_IFREG::Number
(ro) (Static Properties)
S_IFSOCK::Number
(ro) (Static Properties)
S_IFWHT::Number
(ro) (Static Properties)
S_IRGRP::Number
(ro) (Static Properties)
S_IROTH::Number
(ro) (Static Properties)
S_IRUSR::Number
(ro) (Static Properties)
S_IRWXG::Number
(ro) (Static Properties)
S_IRWXO::Number
(ro) (Static Properties)
S_IRWXU::Number
(ro) (Static Properties)
S_ISGID::Number
(ro) (Static Properties)
S_ISUID::Number
(ro) (Static Properties)
S_ISVTX::Number
(ro) (Static Properties)
S_IWOTH::Number
(ro) (Static Properties)
S_IWUSR::Number
(ro) (Static Properties)
S_IXGRP::Number
(ro) (Static Properties)
S_IXOTH::Number
(ro) (Static Properties)
S_IXUSR::Number
(ro) (Static Properties)
TCP_NODELAY::Number
(ro) (Static Properties)
UF_APPEND::Number
(ro) (Static Properties)
UF_IMMUTABLE::Number
(ro) (Static Properties)
UF_NODUMP::Number
(ro) (Static Properties)
UF_OPAQUE::Number
(ro) (Static Properties)
Array poll(set::Object|Array, timeout::Number);
(Static Methods)
Synchronous I/O multiplexing. Waits until a delay expires or until an event occurs on the specified set of FD
objects, returning another set of FD
objects for which events occurred. Note that a more efficient system exists which can be used via the Event
class.
Array
Array of FD
objects with pending events (empty array in case of timeout). The revents
property of every FD
object holds the events which occurred.
set::Object|Array
Object holding FD objects to poll(2)
for. The events
property of every FD
object must have events to poll for.
timeout::Number
Timeout in milliseconds or -1
.
IOException
Object holds details.
client_addr | client_port | errno | events | fd | mode | path | revents
client_addr::String
(ro) (Properties)
Client's remote IP address if any.
client_port::Number
(ro) (Properties)
Client's remote IP port if any.
errno::Number
(ro) (Properties)
Associated error number if any.
events::Number
(rw) (Properties)
FD.POLL*
events we are interested in.
fd::Number
(ro) (Properties)
Internal unix C file descriptor number.
mode::Number
(ro) (Properties)
Modes file was open with if any.
path::String
(ro) (Properties)
Path to open file if any.
revents::Number
(ro) (Properties)
FD.POLL*
received events after FD.poll()
call.
accept | bind | close | connect | fchmod | fchown | fcntl | fdatasync | flock | fstat | ftruncate | get | getsockopt | listen | lseek | open | put | read | set | setsockopt | shutdown | socket | write
FD accept(void);
(Methods)
Attempts to accept a connection. The object must already be a bound socket which is listening.
FD
New client descriptor object.
IOException
Object holds details.
void bind(address::String, port::Number);
(Methods)
Binds the descriptor to the specified address and port. Note that it must be a socket.
address::String
IPv4 address or mask (0.0.0.0
for all local interfaces).
port::Number
Port number.
IOException
Exception object holds details.
Number close(void);
(Methods)
Closes the descriptor wrapped by the object. Note that deleting an FD
object also closes the file descriptor, unless it was associated using FD.set()
.
Number
0 on success or Errno.*
on error (FD.errno
property also set).
void connect(address::String, port::Number);
(Methods)
Attempts connection to the specified destination. If a hostname is given instead of an IPv4 address, it is resolved. Note that the object must be a socket.
address::String
Destination address or host.
port::Number
Destination port.
IOException
Exception object holds details.
void fchmod(mode::Number);
(Methods)
Set file permissions mode.
mode::Number
OR
ed octal mode to set (FD.*
, see fchmod(2)
).
IOException
Object holds details.
SecurityException
Mode not permitted by application access.
void fchown(user::String|Number, group::String|Number);
(Methods)
Set file owner and/or group.
user::String|Number
User name String
or UID Number (-1
to not change).
group::String|Number
Group name String
or GID Number (-1
to not change).
IOException
Object holds details.
Number fcntl(command::Number, flags::Number);
(Methods)
File descriptor control. We only support commands FD.F_GETFL
and FD.F_SETFL
, with flags FD.O_NONBLOCK
and FD.O_APPEND
. See fcntl(2)
.
Number
State of the previous flags (supported only).
command::Number
Command (FD.F_GETFL
or FD.F_SETFL
).
flags::Number
OR
ed flags (FD.O_NONBLOCK
, FD.O_APPEND
).
void fdatasync(void);
(Methods)
Synchronize the data of a file. Useful when necessary to ensure that the written data really is on disk.
IOException
Object holds details
void flock(op::Number);
(Methods)
Apply or remove an advisory lock on an open file. See flock(2)
for more information.
op::Number
Operation to perform (FD.LOCK_*
).
IOException
Object holds details.
Stat fstat(void);
(Methods)
Query status of open file.
Stat
The returned object holds properties about the file. See fstat(2)
for more information.
IOException
Object holds details.
void ftruncate(size::Number);
(Methods)
Truncates file to specified size.
size::Number
Size to truncate file to.
IOException
Error truncating file.
null|String get(void);
(Methods)
Reads data from the socket if any and returns it. The internal buffer size is at most 4KB.
null|String
null
on EOF or a String
with the read data.
IOException
Exception object holds details.
Number getsockopt(name::Number);
(Methods)
Gets current socket options. Unlike BSD/POSIX getsockopt(2)
, always returns a single integer value (-1
in case of SO_LINGER
disabled, or the number of seconds assined to wait if enabled).
Number
Current option value.
name::Number
Option to retreive the value of (FD.SO_*
).
void listen(concurrency::Number);
(Methods)
Listens to the already bound FD.SOCK_STREAM
socket.
concurrency::Number
Number of connections to queue.
IOException
Object has details.
Number lseek(offset::Number, whence::Number);
(Methods)
Reposition read/write file offset.
Number
New file offset relative to beginning of file
offset::Number
Offset to seek to.
whence::Number
How to seek (FD.SEEK_SET
, FD.SEEK_CUR
, FD.SEEK_END
), see lseek(2)
for more information.
IOException
Object holds details.
void open(path::String, flags::Number, mode::Number);
(Methods)
Opens a file with specified flags and mode like open(2)
.
path::String
Path to file to open.
flags::Number
Flags as for open(2)
(FD.O_*
).
mode::Number
Permission mode as for open(2)
.
IOException
Details in exception object.
SecurityException
Path not allowed.
void open(path::String, flags::Number);
(Methods)
Opens a file with specified flags and a default mode.
path::String
Path to file to open.
flags::Number
Flags as for open(2)
(FD.O_*
).
IOException
Details in exception object.
SecurityException
Path not allowed.
Number put(data::*);
(Methods)
Writes a string to the descriptor. Converts the value to a String
as necessary.
Number
Number of bytes written.
data::*
Value to write.
IOException
Details in exception object.
String|null read(size::Number);
(Methods)
Reads data from the descriptor in a binary-safe way, up to the maximum number of specified bytes.
String|null
Data that could be read, or null
on EOF.
size::Number
Maximum read buffer size to use.
IOException
Object holds details.
void set(descriptor::Number);
(Methods)
Associates FD object to an existing internal C file descriptor.
descriptor::Number
File descriptor to wrap FD around.
IOException
Details in exception object.
void setsockopt(name::Number, value::Number);
(Methods)
Sets socket options. Unlike BSD/POSIX setsockopt(2)
, always requires a single integer value (-1
in the case of FD.SO_LINGER
to disable it, or the number of seconds to linger to enable it).
name::Number
Option to change (FD.SO_*
).
value::Number
Value to change option to.
Number shutdown(how::Number);
(Methods)
Shut down part of a full-duplex connection. The socket must already be connected.
Number
0
on success or errno
code on error (Error.*
).
how::Number
What to shut down (FD.*
), see shutdown(2)
.
void socket(domain::Integer, type::Integer, protocol::Integer);
(Methods)
Sets up the FD
object as an IPv4 socket. Currently, only FD.AF_INET
, FD.SOCK_DGRAM
and FD.SOCK_STREAM
are supported. Like C socket(2)
.
domain::Integer
FD.AF_INET
only for now.
type::Integer
Type of socket (FD.SOCK_DGRAM
or FD.SOCK_STREAM
only for now).
protocol::Integer
Usually 0
.
IOException
Exception object holds details.
Number write(data::String);
(Methods)
Writes the contents of the supplied String
to the descriptor. Binary safe.
Number
Number of bytes which could be written.
data::String
Data to write to the descriptor.
IOException
Object holds details.
This class wraps around various file system related unix system calls.
Constructors | Static Properties | Static Methods | Properties | Methods
chdir | chmod | chown | creat | getcwd | lchown | mkdir | mkfifo | mknod | rename | rmdir | stat | symlink | truncate | unlink
void chdir(path::String);
(Static Methods)
Change current directory.
path::String
Path to directory to change to.
IOException
Object holds details.
SecurityException
Application forbidden access to path.
void chmod(path::String, mode::Number);
(Static Methods)
Change permission mode of a file.
path::String
Path to file to affect.
mode::Number
Permission mode to set.
IOException
Object holds details.
SecurityException
Application forbidden to access path.
void chown(path::String, owner::String|Number, group::String|Number);
(Static Methods)
Change owner and/or group of a file. Follow symbolic links.
path::String
Path to file to work on.
owner::String|Number
User name or numeric uid of owner to set, or -1
to leave unchanged.
group::String|Number
Group name or numeric gid of group to set, or -1
to leave unchanged.
IOException
Object holds details.
SecurityException
Application not allowed access to path or to use symbolic-link following functions.
void creat(path::String, mode::Number);
Deprecated (Static Methods)
Create a new file.
path::String
Path to new file to be created.
mode::Number
Permissions mode to set for new file.
IOException
Object holds details.
SecurityException
Application forbidden access.
String getcwd(void);
(Static Methods)
Get current directory.
String
Path of current working directory.
void lchown(path::String, owner::String|Number, group::String|Number);
(Static Methods)
Change owner and/or group of a file. Does not follow symbolic links.
path::String
Path to file to work on.
owner::String|Number
User name or numeric uid of owner to set, or -1
to leave unchanged.
group::String|Number
Group name or numeric gid of group to set, or -1
to leave unchanged.
IOException
Object holds details.
SecurityException
Application not allowed access to path.
void mkdir(path::String, mode::Number);
(Static Methods)
Create a new directory.
path::String
Path to directory to create.
mode::Number
Permission mode for new directory.
IOException
Object holds details.
SecurityException
Application not allowed access to path.
void mkfifo(path::String, mode::Number);
(Static Methods)
Create a FIFO special file.
path::String
Path to new file.
mode::Number
Permissions mode for new file.
IOException
Object holds details.
SecurityException
Application forbidden operation.
void mknod(path::String, mode::Number, dev::Number);
(Static Methods)
Create a new special file.
path::String
Path to new file.
mode::Number
Permissions mode to set for new file.
dev::Number
Device information.
IOException
Object holds details.
SecurityException
Application forbidden operation.
void rename(path1::String, path2::String);
(Static Methods)
Rename a file or directory (path1
to path2
).
path1::String
Path to file to rename.
path2::String
Path to new name.
IOException
Object holds details.
SecurityException
Application forbidden access.
void rmdir(path::String);
(Static Methods)
Delete an empty directory.
path::String
Path to directory to be deleted.
IOException
Object holds details.
SecurityException
Application forbidden access to path.
Stat stat(path::String);
(Static Methods)
Obtain information on file. Follows symbolic links.
Stat
Object holding information about the file.
path::String
Path to file to get information about.
IOException
Object holds details.
SecurityException
Application forbidden access to path, or application is now allowed to use functions which follow symbolic links.
Stat stat(path::String);
(Static Methods)
Obtain information on file. Does not follow symbolic links, information about the link is returned instead.
Stat
Object holding information about the file.
path::String
Path to file to get information about.
IOException
Object holds details.
SecurityException
Application forbidden access to path.
void symlink(path1::String, path2::String);
(Static Methods)
Create a symbolic link (path2
to path1
).
path1::String
Destination path name.
path2::String
Link path name.
IOException
Object holds details.
SecurityException
Application forbidden operation.
void truncate(path::String, size::Number);
(Static Methods)
Sets size of a file.
path::String
Path to file to affect.
size::Number
New size to set for file.
IOException
Object holds details.
SecurityException
Application forbidden access.
void unlink(path::String);
(Static Methods)
Delete a file.
path::String
Path to file to delete.
IOException
Object holds details.
SecurityException
Application forbidden access.
This class consists of a wrapper around C stdio. When it is initialized by the system, three File
objects are also created as first-level objects: stdin
, stdout
and stderr
.
Because various C libraries also work with C FILE
objects, it was important to implement support for stdio
. For instance, the GD
and PG
classes support it.
Constructors | Static Properties | Static Methods | Properties | Methods
void File(path::String, mode::String);
(Constructors)
Opens the specified file in the specified mode.
path::String
Path to file that is to be opened.
mode::String
mode
is identical to C stdio fopen(3)
modes, namely: r
, r+
, w+
, a
and a+
.
IOException
Object holds details.
SecurityException
Forbidden path
.
void File(descriptor::Number, mode::String);
(Constructors)
Instead of opening a file, bind the File
object to a unix file descriptor.
descriptor::Number
The file descriptor may be one of File.STDIN_FILENO
, File.STDOUT_FILENO
, File.STDERR_FILENO
or any other open descriptor from an FD
object obtained via its FD.fd
property.
mode::String
Same as for the other constructor.
IOException
Object holds details.
SEEK_CUR | SEEK_END | SEEK_SET | STDERR_FILENO | STDIN_FILENO | STDOUT_FILENO | _IOFBF | _IOLBF | _IONBF
SEEK_CUR::Number
(ro) (Static Properties)
Seek at offset from the current position.
SEEK_END::Number
(ro) (Static Properties)
Seek from the end of file.
SEEK_SET::Number
(ro) (Static Properties)
Seek at absolute position from beginning of file.
STDERR_FILENO::Number
(ro) (Static Properties)
Unix descriptor 2
.
STDIN_FILENO::Number
(ro) (Static Properties)
Unix descriptor 0
.
STDOUT_FILENO::Number
(ro) (Static Properties)
Unix descriptor 1
.
_IOFBF::Number
(ro) (Static Properties)
Fully buffered.
_IOLBF::Number
(ro) (Static Properties)
Line buffered.
_IONBF::Number
(ro) (Static Properties)
Unbuffered.
popen | remove | strerror | tmpfile
FD popen(command::String, mode::String);
(Static Methods)
Allows to execute a wanted command and to read and/or write to its standard input and output file handles. Returns a new FD
object to this effect.
FD
New FD
object to interract with the command.
command::String
Command to execute.
mode::String
Mode to open the file handle in. Same modes as stdio or File.constructors.FD
.
IOException
Object holds details.
SecurityException
Application not allowed to execute external commands.
void remove(path::String);
(Static Methods)
Deletes the specified file.
path::String
Path to the file to delete.
IOException
Object holds details.
SecurityException
Application forbidden to access path
in write mode.
String strerror(errno::Number);
(Static Methods)
Translate error number to readable form.
String
Translation of supplied error code to string.
errno::Number
Error number to translate.
String strerror(void);
(Static Methods)
Translate error number to readable form.
String
Translation of system C/unix errno
to string.
FD tmpfile(void);
(Static Methods)
Creates a temporary file and returns a new FD
object which can be used to write and read from it, in mode w+
. When this descriptor is closed the file is automatically deleted.
FD
New FD
object to interact with the new temporary file.
IOException
Object holds details.
clearerr | close | eof | error | fileno | flush | getc | gets | purge | putc | read | reopen | rewind | seek | setvbuf | tell | ungetc | write
void clearerr(void);
(Methods)
Clears any pending error condition from File
handle.
IOException
Details in object.
Number close(void);
(Methods)
Closes the file. This file object becomes invalid.
Number
0
on success or an errno
error code.
Boolean eof(void);
(Methods)
Returns End Of File status of the File
handle.
Boolean
true
if EOF was reached; false
otherwise.
IOException
Details in object.
Boolean error(void);
(Methods)
Returns pending error status for File
handle.
Boolean
true
if an error is pending, false
otherwise.
IOException
Details in object.
Number fileno(void);
(Methods)
Obtain internal C unix descriptor from File
handle.
Number
C unix file descriptor number.
IOException
Details in object.
void flush(void);
(Methods)
By default, File
handlers are buffered. This method permits to explicitely flush any pending data on request, causing pending buffers to be written.
IOException
Details in object.
Number getc(void);
(Methods)
Reads a character from file handle.
Number
Code of read character.
IOException
EOF or error; Object hold details.
String gets(size::Number, nostrip::Boolean);
(Methods)
Reads a line from file handle.
String
Line that was read.
size::Number
Maximum buffer size to use to read line. If the buffer is too small partial lines may be returned. Partial lines can be distinguished by the fact that the '\n'
terminator is not present.
nostrip::Boolean
Set to true
if terminating '\n'
or "\r\n"
characters should be retained, or to false
if they should be stripped. Note that if stripping them it becomes impossible to distinguish very long lines which exceed the buffer size from lines which exactly match the buffer size.
IOException
EOF or error; Object holds details.
void purge(void);
(Methods)
While File.flush
permits to write any pending buffers, this method instead drops any pending read data in the read buffer.
IOException
Details in object.
void putc(character::Number);
(Methods)
Writes a character to file handle.
character::Number
Code of character to write.
IOException
Object holds details.
String read(size::Number, nmemb::Number);
(Methods)
Reads data from file handle. Unlike C stdio fread(3)
, returns a String
with the read bytes rather than the number of read elements.
String
String holding the read data (may be shorter than the requested number of bytes to read).
size::Number
Size in bytes of the object to read.
nmemb::Number
Number of size
bytes objects to read.
IOException
Error or EOF; Object holds details.
void reopen(path::String, mode::String);
(Methods)
Reopens/redirects the specified file. This may be useful for instance to redirect the output of stderr
to a file.
path::String
Path of file to open.
mode::String
Mode to open file in; Same as for the File
constructor.
IOException
Details provided in object.
SecurityException
Application forbidden access to path
.
void rewind(void);
(Methods)
Rewind current position in file, that is, resets to position 0
, the file beginning.
IOException
Details in object.
void seek(offset::Number, whence::Number);
(Methods)
Reposition pointer in file.
offset::Number
Offset in file to reposition pointer.
whence::Number
How to reposition the pointer.
IOException
Details in object.
void setvbuf(type::Number, size::Number);
(Methods)
Permits to change the buffering policy of the handle. Unlike stdio setvbuf(3)
, requires two arguments.
type::Number
Type of buffering to use.
size::Number
When buffering is enabled, the size of the internal buffer. Specifying 0
here causes the internal C stdio buffer to be used rather than a custom one.
IOException
Details in object.
Number tell(void);
(Methods)
Query current position in file.
Number
Current offset in file.
IOException
Details in object.
void ungetc(character::Number);
(Methods)
Puts back a previously read character using File.getc()
into the read buffer so that it may be read again.
character::Number
Code of character to push.
IOException
Object holds details.
void write(data::String);
(Methods)
Writes data to file handle. Unlike C stdio fwrite(3)
, Throws an exception on error and is only provided a string with the data to be written rather than object size and count.
data::String
Data to be written.
IOException
Object holds details.
Implements libgd(3)
2.0.33 support for JavaScript. This class provides a container for the various constructors and C-imported static properties.
Constructors | Static Properties | Static Methods | Properties | Methods
GD2_FMT_COMPRESSED | GD2_FMT_RAW | GD_CMP_BACKGROUND | GD_CMP_COLOR | GD_CMP_IMAGE | GD_CMP_INTERLACE | GD_CMP_NUM_COLORS | GD_CMP_SIZE_X | GD_CMP_SIZE_Y | GD_CMP_TRANSPARENT | GD_CMP_TRUECOLOR | gdAlphaOpaque | gdAlphaTransparent | gdAntiAliased | gdArc | gdBrushed | gdChord | gdDashSize | gdDisposalNone | gdDisposalRestoreBackground | gdDisposalRestorePrevious | gdDisposalUnknown | gdEdged | gdFTEX_Big5 | gdFTEX_Shift_JIS | gdFTEX_Unicode | gdMaxColors | gdNoFill | gdPie | gdStyled | gdStyledBrushed | gdTiled | gdTransparent
GD2_FMT_COMPRESSED::Number
(ro) (Static Properties)
GD2_FMT_RAW::Number
(ro) (Static Properties)
GD_CMP_BACKGROUND::Number
(ro) (Static Properties)
GD_CMP_COLOR::Number
(ro) (Static Properties)
GD_CMP_IMAGE::Number
(ro) (Static Properties)
GD_CMP_INTERLACE::Number
(ro) (Static Properties)
GD_CMP_NUM_COLORS::Number
(ro) (Static Properties)
GD_CMP_SIZE_X::Number
(ro) (Static Properties)
GD_CMP_SIZE_Y::Number
(ro) (Static Properties)
GD_CMP_TRANSPARENT::Number
(ro) (Static Properties)
GD_CMP_TRUECOLOR::Number
(ro) (Static Properties)
gdAlphaOpaque::Number
(ro) (Static Properties)
gdAlphaTransparent::Number
(ro) (Static Properties)
gdAntiAliased::Number
(ro) (Static Properties)
gdArc::Number
(ro) (Static Properties)
gdBrushed::Number
(ro) (Static Properties)
gdChord::Number
(ro) (Static Properties)
gdDashSize::Number
(ro) (Static Properties)
gdDisposalNone::Number
(ro) (Static Properties)
gdDisposalRestoreBackground::Number
(ro) (Static Properties)
gdDisposalRestorePrevious::Number
(ro) (Static Properties)
gdDisposalUnknown::Number
(ro) (Static Properties)
gdEdged::Number
(ro) (Static Properties)
gdFTEX_Big5::Number
(ro) (Static Properties)
gdFTEX_Shift_JIS::Number
(ro) (Static Properties)
gdFTEX_Unicode::Number
(ro) (Static Properties)
gdMaxColors::Number
(ro) (Static Properties)
gdNoFill::Number
(ro) (Static Properties)
gdPie::Number
(ro) (Static Properties)
gdStyled::Number
(ro) (Static Properties)
gdStyledBrushed::Number
(ro) (Static Properties)
gdTiled::Number
(ro) (Static Properties)
gdTransparent::Number
(ro) (Static Properties)
create | createFromGd | createFromGd2 | createFromGd2Part | createFromGd2PartStr | createFromGd2Str | createFromGdStr | createFromGif | createFromGifStr | createFromJpeg | createFromJpegStr | createFromPng | createFromPngStr | createFromWBMP | createFromWBMPStr | createFromXbm | createFromXpm | createTrueColor | ftUseFontConfig | trueColor | trueColorAlpha
GDImage create(sx::Number, sy::Number);
(Static Methods)
Create a palette-based 256-color (8bpp) image.
GDImage
New image object.
sx::Number
Image width in pixels.
sy::Number
Image height in pixels.
GDException
GDImage createFromGd(fh::File);
(Static Methods)
Load GD image from specified file handle.
GDImage
Loaded image object.
fh::File
File handle to load image from. The handle is not closed.
GDException
GDImage createFromGd2(fh::File);
(Static Methods)
Load Gd2 image from specified file handle.
GDImage
Loaded image object.
fh::File
File handle to load image from. The handle is not closed.
GDException
GDImage createFromGd2Part(fh::File, srcX::Number, srcY::Number, w::Number, h::Number);
(Static Methods)
Load part of a Gd2 image from specified file handle.
GDImage
fh::File
File handle to load image from. The handle is not closed.
srcX::Number
X location of top-left corner in source image.
srcY::Number
Y location of top-left corner in source image.
w::Number
Width of image part.
h::Number
Height of image part.
GDException
GDImage createFromGd2PartStr(data::String, srcX::Number, srcY::Number, w::Number, h::Number);
(Static Methods)
Load part of a Gd2 image from specified data string.
GDImage
data::String
Data to load image from.
srcX::Number
X location of top-left corner in source image.
srcY::Number
Y location of top-left corner in source image.
w::Number
Width of image part.
h::Number
Height of image part.
GDException
GDImage createFromGd2Str(data::String);
(Static Methods)
Load Gd2 image from specified data string.
GDImage
data::String
Data to load image from.
GDException
GDImage createFromGdStr(data::String);
(Static Methods)
Load GD image from specified data string.
GDImage
data::String
Data to load image from.
GDException
GDImage createFromGif(fh::File);
(Static Methods)
Load GIF image from specified file handle.
GDImage
Loaded image object.
fh::File
File handle to load image from. The handle is not closed.
GDException
GDImage createFromGifStr(data::String);
(Static Methods)
Load GIF image from specified data string.
GDImage
data::String
Data to load image from.
GDException
GDImage createFromJpeg(fh::File);
(Static Methods)
Load JPEG image from specified file handle.
GDImage
Loaded image object.
fh::File
File handle to load image from. The handle is not closed.
GDException
GDImage createFromJpegStr(data::String);
(Static Methods)
Load JPEG image from specified data string.
GDImage
data::String
Data to load image from.
GDException
GDImage createFromPng(fh::File);
(Static Methods)
Load PNG image from specified file handle.
GDImage
Loaded image object.
fh::File
File handle to load image from. The handle is not closed.
GDException
GDImage createFromPngStr(data::String);
(Static Methods)
Load PNG image from specified data string.
GDImage
data::String
Data to load image from.
GDException
GDImage createFromWBMP(fh::File);
(Static Methods)
Load WBMP image from specified file handle.
GDImage
Loaded image object.
fh::File
File handle to load image from. The handle is not closed.
GDException
GDImage createFromWBMPStr(data::String);
(Static Methods)
Load WBMP image from specified data string.
GDImage
data::String
Data to load image from.
GDException
GDImage createFromXbm(fh::File);
(Static Methods)
Load XBM image from specified file handle.
GDImage
Loaded image object.
fh::File
File handle to load image from. The handle is not closed.
GDException
GDImage createFromXpm(path::String);
(Static Methods)
Load XPM image from specified file path.
GDImage
path::String
Path to file to load image from.
GDException
SecurityException
Application forbidden to access path
.
GDImage createTrueColor(sx::Number, sy::Number);
(Static Methods)
Create a true color (32bpp) image.
GDImage
New image object.
sx::Number
Image width in pixels.
sy::Number
Image height in pixels.
GDException
Boolean ftUseFontConfig(enable::Boolean);
(Static Methods)
Enable or disable FontConfig font name resolving.
Boolean
true
if the libfontconfig(3)
library is available, false
if not.
enable::Boolean
Specifies weither FontConfig resolving should be on or off (true
or false
, respectively).
Number trueColor(r::Number, g::Number, b::Number);
(Static Methods)
Obtain RGB color for specified composite values.
Number
RGB resulting color.
r::Number
Red index (0
- 255
).
g::Number
Green index (0
- 255
).
b::Number
Blue index (0
- 255
).
Number trueColorAlpha(r::Number, g::Number, b::Number, a::Number);
(Static Methods)
Obtain RGBA color for specified composite values.
Number
RGBA resulting color.
r::Number
Red index (0
- 255
).
g::Number
Green index (0
- 255
).
b::Number
Blue index (0
- 255
).
a::Number
Alpha/transparency index (0
- 255
).
A GD native font object. Of this type are the following global objects: gdFontSmall
, gdFontLarge
, gdFontMediumBold
, gdFontGiant
, gdFontTiny
.
Constructors | Static Properties | Static Methods | Properties | Methods
Represents an image object. Created via the GD.*
static methods.
Constructors | Static Properties | Static Methods | Properties | Methods
sx::Number
(ro) (Properties)
X size (width) in pixels.
sy::Number
(ro) (Properties)
Y size (height) in pixels.
alpha | alphaBlending | arc | blue | boundsSafe | charRight | charUp | colorAllocate | colorAllocateAlpha | colorClosest | colorClosestAlpha | colorClosestHWB | colorDeallocate | colorExact | colorResolve | colorResolveAlpha | colorTransparent | colorsTotal | compare | copy | copyMerge | copyMergeGray | copyResampled | copyResized | copyRotated | createPaletteFromTrueColor | dashedLine | destroy | fill | fillToBorder | filledEllipse | filledPolygon | filledRectangle | gd | gd2 | gd2Str | gdStr | getClip | getInterlaced | getPixel | getTransparent | gif | gifAnimAdd | gifAnimAddStr | gifAnimBegin | gifAnimBeginStr | gifAnimEnd | gifAnimEndStr | gifStr | green | imageSX | imageSY | interlace | jpeg | jpegStr | line | openPolygon | paletteCopy | png | pngEx | pngExStr | pngStr | polygon | rectangle | red | saveAlpha | setAntiAliased | setAntiAliasedDontBlend | setBrush | setClip | setPixel | setStyle | setThickness | setTile | squareToCircle | stringFt | stringFtCircle | stringFtEx | stringRight | stringUp | trueColorToPalette | wbmp | wbmpStr
Number alpha(color::Number);
(Methods)
Query alpha channel component for specified color index.
Number
Alpha value (0
(GD.gdAlphaOpaque
) - 127
(GD.gdAlphaTransparent
)).
color::Number
void alphaBlending(enable::Boolean);
(Methods)
Enable or disable alpha blending. Only affects true-color images.
enable::Boolean
void arc(centerX::Number, centerY::Number, width::Number, height::Number, startAngle::Number, endAngle::Number, color::Number);
(Methods)
Draws an arc.
centerX::Number
centerY::Number
width::Number
height::Number
startAngle::Number
endAngle::Number
color::Number
void arc(centerX::Number, centerY::Number, width::Number, height::Number, startAngle::Number, endAngle::Number, color::Number, style::Number);
(Methods)
Draws an optionally filled arc.
centerX::Number
centerY::Number
width::Number
height::Number
startAngle::Number
endAngle::Number
color::Number
style::Number
OR
ed flags among GD.gdArc
, GD.gdChord
, GD.gdPie
(synonym to GD.gdChord
), GD.gdNoFill
, GD.gdNoEdged
.
Number blue(color::Number);
(Methods)
Obtain blue channel value for specified color.
Number
Blue value.
color::Number
Color to extract value from.
Boolean boundsSafe(x::Number, y::Number);
(Methods)
Verify if specified pixel is within the clipping rectangle.
Boolean
x::Number
y::Number
void charRight(font::GDFont, x::Number, y::Number, color::Number);
(Methods)
Draw a single character and move cursor right.
font::GDFont
x::Number
y::Number
color::Number
void charUp(font::GDFont, x::Number, y::Number, color::Number);
(Methods)
Draw a single character and move cursor up.
font::GDFont
x::Number
y::Number
color::Number
Number colorAllocate(red::Number, green::Number, blue::Number);
(Methods)
In palette-indexed mode, allocates a color and sets its RGB values. In true-color mode, returns a packed representation of the RGB values.
Number
New color. In the case of pallete-indexed image, may return -1
when all colors have been allocated (GD.gdMaxColors
or 256
total colors). Use GDImage.colorClosest()
and friends in this case.
red::Number
0
- 255
.
green::Number
0
- 255
.
blue::Number
0
- 255
.
Number colorAllocateAlpha(red::Number, green::Number, blue::Number, alpha::Number);
(Methods)
In palette-indexed mode, allocates a color and sets its RGBA values. In true-color mode, returns a packed representation of the RGBA values.
Number
New color. In the case of pallete-indexed image, may return -1
when all colors have been allocated (GD.gdMaxColors
or 256
total colors). Use GDImage.colorClosestAlpha()
and friends in this case.
red::Number
0
- 255
.
green::Number
0
- 255
.
blue::Number
0
- 255
.
alpha::Number
0
(GD.gdAlphaOpaque
) - 127
(GD.gdAlphaTransparent
).
Number colorClosest(red::Number, green::Number, blue::Number);
(Methods)
In palette-indexed mode, returns the existing color which most closely approximates to the specified color. In true-color mode, returns the exact color specified.
Number
Color or -1
if no colors were allocated (in indexed mode only).
red::Number
0
- 255
.
green::Number
0
- 255
.
blue::Number
0
- 255
.
Number colorClosestAlpha(red::Number, green::Number, blue::Number, alpha::Number);
(Methods)
In palette-indexed mode, returns the existing color which most closely approximates to the specified color. In true-color mode, returns the exact color specified.
Number
Color or -1
if no colors were allocated (in indexed mode only).
red::Number
0
- 255
.
green::Number
0
- 255
.
blue::Number
0
- 255
.
alpha::Number
0
(GD.gdAlphaOpaque
) - 127
(GD.gdAlphaTransparent
).
Number colorClosestHWB(hue::Number, whiteness::Number, brightness::Number);
(Methods)
Like GDImage.closestColor()
but is specified hue, whiteness and brightness instead of RGB values.
Number
Color or -1
.
hue::Number
0
- 255
.
whiteness::Number
0
- 255
.
brightness::Number
0
- 255
.
void colorDeallocate(color::Number);
(Methods)
Dealocates a color. The next allocation will use this slot. Does nothing for true-color images.
color::Number
Number colorExact(red::Number, green::Number, blue::Number);
(Methods)
Like GDImage.colorClosest()
but only returns exact matches.
Number
Color or -1
if no exact match was found.
red::Number
0
- 255
.
green::Number
0
- 255
.
blue::Number
0
- 255
.
Number colorResolve(red::Number, green::Number, blue::Number);
(Methods)
Like GDImage.colorExact()
but attempts to allocate a new color like GDImage.colorAllocate()
if no exact match was found.
Number
Color or -1
if no color could be allocated (in indexed mode only).
red::Number
0
- 255
.
green::Number
0
- 255
.
blue::Number
0
- 255
.
Number colorResolveAlpha(red::Number, green::Number, blue::Number, alpha::Number);
(Methods)
Like GDImage.colorExactAlpha()
but attempts to allocate a new color like GDImage.colorAllocateAlpha()
if no exact match was found.
Number
Color or -1
if no color could be allocated (in indexed mode only).
red::Number
0
- 255
.
green::Number
0
- 255
.
blue::Number
0
- 255
.
alpha::Number
0
(GD.gdAlphaOpaque
) - 127
(GD.gdAlphaTransparent
).
void colorTransparent(color::Number);
(Methods)
Sets transparent color index for the image.
color::Number
An already allocated index color, or -1
to disable.
Number colorsTotal(void);
(Methods)
Obtain number of allocated colors for palette-indexed images.
Number
Number of colors. Undefined for true-color images, and should not be used.
Number compare(other::GDImage);
(Methods)
Compare this image to another one.
Number
bitmap A bitmap to ce compared against the GD.GD_CMP_*
bits.
other::GDImage
Other image to compare this one with.
void copy(destination::GDImage, dstX::Number, dstY::Number, srcX::Number, srcY::Number, width::Number, height::Number);
(Methods)
Copy a rectangular portion of this image to another one.
destination::GDImage
Image to copy to.
dstX::Number
dstY::Number
srcX::Number
srcY::Number
width::Number
height::Number
void copyMerge(destination::GDImage, dstX::Number, dstY::Number, srcX::Number, srcY::Number, width::Number, height::Number, pct::Number);
(Methods)
Like GDImage.copy()
but merges both images on the destination using the specified transparency.
destination::GDImage
Image to copy to.
dstX::Number
dstY::Number
srcX::Number
srcY::Number
width::Number
height::Number
pct::Number
Factor by which to merge the images. 100
means totally opaque and is identical to using GDImage.copy()
.
void copyMergeGray(destination::GDImage, dstX::Number, dstY::Number, srcX::Number, srcY::Number, width::Number, height::Number, pct::Number);
(Methods)
Like GDImage.copyMerge()
but preserves the hue of the source by converting the destination image to gray scale.
destination::GDImage
Image to copy to.
dstX::Number
dstY::Number
srcX::Number
srcY::Number
width::Number
height::Number
pct::Number
Factor by which to merge the images. 100
means totally opaque and is identical to using GDImage.copy()
.
void copyResampled(destination::GDImage, dstX::Number, dstY::Number, srcX::Number, srcY::Number, dstWidth::Number, dstHeight::Number, srcWidth::Number, srcHeight::Number);
(Methods)
Like GDImage.methods.copyResized()
but yields in better quality (yet processing takes more resources).
destination::GDImage
Destination image to copy to.
dstX::Number
dstY::Number
srcX::Number
srcY::Number
dstWidth::Number
dstHeight::Number
srcWidth::Number
srcHeight::Number
void copyResized(destination::GDImage, dstX::Number, dstY::Number, srcX::Number, srcY::Number, dstWidth::Number, dstHeight::Number, srcWidth::Number, srcHeight::Number);
(Methods)
Copies image to another while resizing.
destination::GDImage
Destination image to copy to.
dstX::Number
dstY::Number
srcX::Number
srcY::Number
dstWidth::Number
dstHeight::Number
srcWidth::Number
srcHeight::Number
void copyRotated(destination::GDImage, dstX::Number, dstY::Number, srcX::Number, srcY::Number, srcWidth::Number, srcHeight::Number, angle::Number);
(Methods)
Copies this image to specified destination image while rotating.
destination::GDImage
Destination image to copy to.
dstX::Number
dstY::Number
srcX::Number
srcY::Number
srcWidth::Number
srcHeight::Number
angle::Number
GDImage createPaletteFromTrueColor(dither::Boolean, colorsWanted::Number);
(Methods)
Creates a new palettized image from a true-color one. It is generally recommended to use true-color images instead of palette-indexed ones.
GDImage
dither::Boolean
true
to dither image or false
not to.
colorsWanted::Number
Number of colors wanted (0
- 256
). 256
recommended.
GDException
void dashedLine(x1::Number, y1::Number, x2::Number, y2::Number, col::Number);
Deprecated (Methods)
Draw dashed line in specified color.
x1::Number
y1::Number
x2::Number
y2::Number
col::Number
void destroy(void);
(Methods)
Destroy the image and free its associated memory. The object becomes invalid.
void fill(x::Number, y::Number, color::Number);
(Methods)
Fill area from specified center until another color is found.
x::Number
y::Number
color::Number
void fillToBorder(x::Number, y::Number, borderColor::Number, color::Number);
(Methods)
Fill area from specified center to border color.
x::Number
y::Number
borderColor::Number
color::Number
void filledEllipse(centerX::Number, centerY::Number, width::Number, height::Number, color::Number);
(Methods)
Draws a filled ellipse.
centerX::Number
centerY::Number
width::Number
height::Number
color::Number
void filledPolygon(points::Array, color::Number);
(Methods)
Draws a filled polygon which is automatically closed as necessary.
points::Array
Array of Numbers. One pair per point coordinate.
color::Number
void filledRectangle(x1::Number, y1::Number, x2::Number, y2::Number, color::Number);
(Methods)
Draws a filled rectangle.
x1::Number
y1::Number
x2::Number
y2::Number
color::Number
void gd(fh::File);
(Methods)
Saves image as GD to specified file handle. GD is not a general purpose format and is not compressed. It may be useful for fast loading.
fh::File
File handle to save to. The handle is not closed.
void gd2(fh::File, chunkSize::Number, fmt::Number);
(Methods)
Saves image as GD2 to specified file handle. GD2 is not a general purpose format. It may be useful for fast loading and saving of image parts.
fh::File
File handle to save to. The handle is not closed.
chunkSize::Number
Subimage size or 0
to use the default.
fmt::Number
GD.GD2_FMT_COMPRESSED
or GD.GD2_FMT_RAW
.
String gd2Str(chunkSize::Number, fmt::Number);
(Methods)
Saves image as GD2 to binary string. GD2 is not a general purpose format. It may be useful for fast loading and saving of image parts.
String
String holding the image data.
chunkSize::Number
Subimage size or 0
to use the default.
fmt::Number
GD.GD2_FMT_COMPRESSED
or GD.GD2_FMT_RAW
.
GDException
String gdStr(void);
(Methods)
Saves image as GD to binary string. GD is not a general purpose format and is not compressed. It may be useful for fast loading.
String
String holding the image data.
GDException
Object getClip(void);
(Methods)
Obtain current clipping rectangle.
Object
An object with the properties x1
, y1
, x2
and y2
set.
Boolean getInterlaced(void);
(Methods)
Verify if image is interlaced.
Boolean
Interlaced status.
Number getPixel(x::Number, y::Number);
(Methods)
Query color index at specified pixel.
Number
color
x::Number
y::Number
Number getTransparent(void);
(Methods)
Obtain transparent color index from the image.
Number
Current transparent color index or -1
if there is no transparent color.
void gif(fh::File);
(Methods)
Saves image as GIF to specified file handle.
fh::File
File handle to save to. The handle is not closed.
void gifAnimAdd(fh::File, localCM::Number, leftOff::Number, topOff::Number, delay::Number, disposal::Number, *::GDImage|null);
(Methods)
Writes frame to the specified file handle.
fh::File
File handle to write to. The handle is not closed.
localCM::Number
1
to use a local color map or 0
to use the global one.
leftOff::Number
Left offset of image in animation, usually 0
.
topOff::Number
Top offset of image in animation, usually 0
.
delay::Number
Delay between this frame and the previous frame, in hundredths of a second units.
disposal::Number
GD.gdDisposalNone
meaning that the pixels changed by this frame should remain on the display when the next framebegins to render or GD.gdDisposalUnknown
(not recommended).
*::GDImage|null
Previous image frame or null
. Used for optimization. GD.gdDisposalNone
is assumed if this is present.
String gifAnimAddStr(localCM::Number, leftOff::Number, topOff::Number, delay::Number, disposal::Number, *::GDImage|null);
(Methods)
Writes frame to a string.
String
Image frame data.
localCM::Number
1
to use a local color map or 0
to use the global one.
leftOff::Number
Left offset of image in animation, usually 0
.
topOff::Number
Top offset of image in animation, usually 0
.
delay::Number
Delay between this frame and the previous frame, in hundredths of a second units.
disposal::Number
GD.gdDisposalNone
meaning that the pixels changed by this frame should remain on the display when the next framebegins to render or GD.gdDisposalUnknown
(not recommended).
*::GDImage|null
Previous image frame or null
. Used for optimization. GD.gdDisposalNone
is assumed if this is present.
GDException
void gifAnimBegin(fh::File, globalCM::Number, loops::Number);
(Methods)
Writes GIF animation header to specified file handle. Necessary to start GIF animations.
fh::File
File handle to write to. The handle is not closed.
globalCM::Number
Nonzero means that a global color map should be used to reduce the size of the animation. 1
to write a global colormap, 0
not to, -1
to use the default which is currently like 1
.
loops::Number
0
or greater to write the number of loops wanted, 0
meaning infinite. -1
doesn't write the extension and means no looping.
void gifAnimBeginStr(globalCM::Number, loops::Number);
(Methods)
Writes GIF animation header to a string. Necessary to start GIF animations.
globalCM::Number
Nonzero means that a global color map should be used to reduce the size of the animation. 1
to write a global colormap, 0
not to, -1
to use the default which is currently like 1
.
loops::Number
0
or greater to write the number of loops wanted, 0
meaning infinite. -1
doesn't write the extension and means no looping.
void gifAnimEnd(fh::File);
(Methods)
Writes end of GIF animation to specified file handle.
fh::File
File handle to write to. The handle is not closed.
String gifAnimEndStr(void);
(Methods)
Writes end of GIF to a string.
String
Footer data.
GDException
String gifStr(void);
(Methods)
Saves image as GIF to binary string.
String
String holding the image data.
GDException
Number green(color::Number);
(Methods)
Obtain green channel value for specified color.
Number
Green value.
color::Number
Color to extract value from.
Number imageSX(void);
(Methods)
Obtain image width in pixels.
Number
Number imageSY(void);
(Methods)
Obtain image height in pixels.
Number
void interlace(interlace::Boolean);
(Methods)
Specifies if the image should be stored in linear or interlaced mode. Only useful when saving images in JPEG or PNG format. Note that some viewers will not progressively display interlace images as expected but will simply display them at once.
interlace::Boolean
void jpeg(fh::File, quality::Number);
(Methods)
Saves image as JPEG to specified file handle.
fh::File
File handle to save to. The handle is not closed.
quality::Number
JPEG quality index. Negative to use the default quality. Should be in the range of 0
to 95
otherwise.
String jpegStr(quality::Number);
(Methods)
Saves image as JPEG to binary string.
String
String holding the binary image data.
quality::Number
JPEG quality index. Negative to use the default quality. Should be in the range of 0
to 95
otherwise.
GDException
void line(x1::Number, y1::Number, x2::Number, y2::Number, col::Number);
(Methods)
Draw line in specified color.
x1::Number
y1::Number
x2::Number
y2::Number
col::Number
void openPolygon(points::Array, color::Number);
(Methods)
Draws a polygon which is not automatically closed.
points::Array
Array of Numbers. One pair per point coordinate.
color::Number
void paletteCopy(destination::GDImage);
(Methods)
Copies the palette of this image to the destination image using approximated color matching as necessary.
destination::GDImage
Destination image to copy palette to.
void png(fh::File);
(Methods)
Saves image as PNG to specified file handle.
fh::File
File handle to save to. The handle is not closed.
void pngEx(fh::File, level::Number);
(Methods)
Saves image as PNG to specified file handle and wanted compression level.
fh::File
File handle to save to. The handle is not closed.
level::Number
0
- 9
or -1
for default level.
String pngExStr(level::Number);
(Methods)
Saves image as PNG to binary string with wanted compression level.
String
String holding the image data.
level::Number
0
- 9
or -1
for default level.
GDException
String pngStr(void);
(Methods)
Saves image as PNG to binary string.
String
String holding the image data.
GDException
void polygon(points::Array, color::Number);
(Methods)
Draws a polygon which is automatically closed if necessary.
points::Array
Array of Numbers. One pair per point coordinate.
color::Number
void rectangle(x1::Number, y1::Number, x2::Number, y2::Number, color::Number);
(Methods)
Draws a rectangle.
x1::Number
y1::Number
x2::Number
y2::Number
color::Number
Number red(color::Number);
(Methods)
Obtain red channel value for specified color.
Number
Red value.
color::Number
Color to extract value from.
void saveAlpha(enable::Boolean);
(Methods)
Enable or disable saving of alpha information. Note that for alpha values to actually be stored in the image blending must be turned off.
enable::Boolean
void setAntiAliased(color::Number);
(Methods)
Sets the antialiasing color.
color::Number
void setAntiAliasedDontBlend(color::Number, color2::Number);
(Methods)
Sets antialiasing color and color to use not to blend.
color::Number
color2::Number
void setBrush(brush::GDImage);
(Methods)
Sets an image to use as a brush for painting.
brush::GDImage
void setClip(x1::Number, y1::Number, x2::Number, y2::Number);
(Methods)
Sets the clipping area. Any drawing outside the area is invisible. The default clipping area is the image size. Can be called multiple times.
x1::Number
y1::Number
x2::Number
y2::Number
void setPixel(x::Number, y::Number, col::Number);
(Methods)
Plots a pixel in wanted color.
x::Number
y::Number
col::Number
void setStyle(style::Array);
(Methods)
Sets line drawing style.
style::Array
Array of Numbers specifying a sequence of colors.
void setThickness(thickness::Number);
(Methods)
Sets drawing thickness.
thickness::Number
Thickness in pixels.
void setTile(tile::GDImage);
(Methods)
Sets an image to use as a filling pattern.
tile::GDImage
void squareToCircle(radius::Number);
(Methods)
Transforms the image to a circle by using polar coordinates transform. The image must be square, but can be any size.
radius::Number
Array stringFt(fg::Number, fontname::String, ptsize::Number, angle::Number, x::Number, y::Number, string::String, draw::Boolean);
(Methods)
Recommended. Draw string using the FreeType2 library, using a TrueType font (ttf) and anti-aliasing.
Array
An array of 8 Number elements, which indexes hold:
0 - lower left corner, X position
1 - lower left corner, Y position
2 - lower right corner, X position
3 - lower right corner, Y position
4 - upper right corner, X position
5 - upper right corner, Y position
6 - upper left corner, X position
7 - upper left corner, Y position
fg::Number
Color to draw in. Use the negative of the color to disable anti-aliasing.
fontname::String
Font name. Absolute path to ttf font file, relative path to GD compiled-in DEFAULT_FONTPATH
macro or to environment variable GDFONTPATH
. Can also be the name of a font rather than a path if fontconfig is enabled.
ptsize::Number
Point size to draw font into.
angle::Number
Angle of drawing, counter-clockwise, with 0 radians (0 degrees) at 3 o'clock and PI
/2 radians (90 degrees) at 12 o'clock.
x::Number
X position to start at.
y::Number
Y position to start at.
string::String
String to draw.
draw::Boolean
If false
, returns the bounding box but does not draw the text. A relatively cheap operation when done before calling the function with true
.
GDException
Object holds details.
SecurityException
Path to font not allowed.
void stringFtCircle(centerX::Number, centerY::Number, radius::Number, textRadius::Number, fillPortion::Number, font::String, points::Number, top::String, bottom::String, fgColor::Number);
(Methods)
Draw text in a circle manner.
centerX::Number
Center of the circle's X position.
centerY::Number
Center of the circle's Y position.
radius::Number
Radius of circle.
textRadius::Number
Radius of text (determins the height of characters).
fillPortion::Number
Also determins the size of the text.
font::String
Font to use.
points::Number
Size in points.
top::String
Text that is to be written clockwise along the top.
bottom::String
Text that is to be written couterclockwise along the bottom.
fgColor::Number
Text color.
GDException
Object stringFtEx(fg::Number, fontname::String, ptsize::Number, angle::Number, x::Number, y::Number, string::String, options::Object|null, draw::Boolean);
(Methods)
Recommended. Draw string using the FreeType2 library, using a TrueType font (ttf) and anti-aliasing. With more options than GDImage.stringFt
.
Object
An object with the following properties set:
xshow::String
- a string holding necessary values for applications which need to know where every character begins.
fontpath::String
- Actual path to font that was selected.
brect::Object
- Same as the brect
object returned by GDImage.stringFt()
.
fg::Number
Color to draw in. Use the negative of the color to disable anti-aliasing.
fontname::String
Font name. Absolute path to ttf font file, relative path to GD compiled-in DEFAULT_FONTPATH
macro or to environment variable GDFONTPATH
. Can also be the name of a font rather than a path if fontconfig is enabled.
ptsize::Number
Point size to draw font into.
angle::Number
Angle of drawing, counter-clockwise, with 0 radians (0 degrees) at 3 o'clock and PI
/2 radians (90 degrees) at 12 o'clock.
x::Number
X position to start at.
y::Number
Y position to start at.
string::String
String to draw.
options::Object|null
null
, or an object with the optional configuration properties:
linespacing::Number
- Inter-line spacing. 1.0
minimum for lines not to collide.
charmap::Number
- Character map number (GD.gdFTEX_Unicode
, GD.gdFTEX_Shift_JIS
or GD.gdFTEX_Big5
). Unicode is the default.
hdpi::Number
- Horizontal DPI.
vdpi::Number
- Vertical DPI.
draw::Boolean
If false
, returns the bounding box but does not draw the text. A relatively cheap operation when done before calling the function with true
.
GDException
Object holds details.
SecurityException
Path to font not allowed.
void stringRight(font::GDFont, x::Number, y::Number, text::String, color::Number);
(Methods)
Draw a string of characters rightwards.
font::GDFont
x::Number
y::Number
text::String
color::Number
void stringUp(font::GDFont, x::Number, y::Number, text::String, color::Number);
(Methods)
Draw a string of characters upwards.
font::GDFont
x::Number
y::Number
text::String
color::Number
void trueColorToPalette(dither::Boolean, colorsWanted::Number);
(Methods)
Convert image from true-color to palettized. It is generally recommended to use true-color images instead of palette-indexed ones.
dither::Boolean
true
to dither image or false
not to.
colorsWanted::Number
Number of colors wanted (0
- 256
). 256
recommended.
void wbmp(fh::File, fg::Number);
(Methods)
Saves image as monochrome WBMP to specified file handle.
fh::File
File handle to save to. The handle is not closed.
fg::Number
Forground color.
String wbmpStr(fg::Number);
(Methods)
Saves image as monochrome WBMP to binary string.
String
String holding the image data.
fg::Number
Foreground color.
GDException
This class allows to configure the environment and create connections to PostgreSQL. It also serves as a container for a number of static properties which are required by the libpq(3)
API, which we map to rather closely. This API was mostly modeled after the PostgreSQL 8.1.4 libpq(3)
, yet an effort was made to be OO friendly.
Constructors | Static Properties | Static Methods | Properties | Methods
CONNECTION_AUTH_OK | CONNECTION_AWAITING_RESPONSE | CONNECTION_BAD | CONNECTION_MADE | CONNECTION_OK | CONNECTION_SETENV | CONNECTION_SSL_STARTUP | CONNECTION_STARTED | INV_READ | INV_WRITE | InvalidOid | PGRES_BAD_RESPONSE | PGRES_COMMAND_OK | PGRES_COPY_IN | PGRES_COPY_OUT | PGRES_EMPTY_QUERY | PGRES_FATAL_ERROR | PGRES_NONFATAL_ERROR | PGRES_POLLING_FAILED | PGRES_POLLING_OK | PGRES_POLLING_READING | PGRES_POLLING_WRITING | PGRES_TUPLES_OK | PG_DIAG_CONTEXT | PG_DIAG_INTERNAL_POSITION | PG_DIAG_INTERNAL_QUERY | PG_DIAG_MESSAGE_DETAIL | PG_DIAG_MESSAGE_HINT | PG_DIAG_MESSAGE_PRIMARY | PG_DIAG_SEVERITY | PG_DIAG_SOURCE_FILE | PG_DIAG_SOURCE_FUNCTION | PG_DIAG_SOURCE_LINE | PG_DIAG_SQLSTATE | PG_DIAG_STATEMENT_POSITION | PQERRORS_DEFAULT | PQERRORS_TERSE | PQERRORS_VERBOSE | PQTRANS_ACTIVE | PQTRANS_IDLE | PQTRANS_INERROR | PQTRANS_INTRANS | PQTRANS_UNKNOWN | SEEK_CUR | SEEK_END | SEEK_SET
CONNECTION_AUTH_OK::Number
(ro) (Static Properties)
CONNECTION_AWAITING_RESPONSE::Number
(ro) (Static Properties)
CONNECTION_BAD::Number
(ro) (Static Properties)
CONNECTION_MADE::Number
(ro) (Static Properties)
CONNECTION_OK::Number
(ro) (Static Properties)
CONNECTION_SETENV::Number
(ro) (Static Properties)
CONNECTION_SSL_STARTUP::Number
(ro) (Static Properties)
CONNECTION_STARTED::Number
(ro) (Static Properties)
INV_READ::Number
(ro) (Static Properties)
INV_WRITE::Number
(ro) (Static Properties)
InvalidOid::Number
(ro) (Static Properties)
PGRES_BAD_RESPONSE::Number
(ro) (Static Properties)
PGRES_COMMAND_OK::Number
(ro) (Static Properties)
PGRES_COPY_IN::Number
(ro) (Static Properties)
PGRES_COPY_OUT::Number
(ro) (Static Properties)
PGRES_EMPTY_QUERY::Number
(ro) (Static Properties)
PGRES_FATAL_ERROR::Number
(ro) (Static Properties)
PGRES_NONFATAL_ERROR::Number
(ro) (Static Properties)
PGRES_POLLING_FAILED::Number
(ro) (Static Properties)
PGRES_POLLING_OK::Number
(ro) (Static Properties)
PGRES_POLLING_READING::Number
(ro) (Static Properties)
PGRES_POLLING_WRITING::Number
(ro) (Static Properties)
PGRES_TUPLES_OK::Number
(ro) (Static Properties)
PG_DIAG_CONTEXT::Number
(ro) (Static Properties)
PG_DIAG_INTERNAL_POSITION::Number
(ro) (Static Properties)
PG_DIAG_INTERNAL_QUERY::Number
(ro) (Static Properties)
PG_DIAG_MESSAGE_DETAIL::Number
(ro) (Static Properties)
PG_DIAG_MESSAGE_HINT::Number
(ro) (Static Properties)
PG_DIAG_MESSAGE_PRIMARY::Number
(ro) (Static Properties)
PG_DIAG_SEVERITY::Number
(ro) (Static Properties)
PG_DIAG_SOURCE_FILE::Number
(ro) (Static Properties)
PG_DIAG_SOURCE_FUNCTION::Number
(ro) (Static Properties)
PG_DIAG_SOURCE_LINE::Number
(ro) (Static Properties)
PG_DIAG_SQLSTATE::Number
(ro) (Static Properties)
PG_DIAG_STATEMENT_POSITION::Number
(ro) (Static Properties)
PQERRORS_DEFAULT::Number
(ro) (Static Properties)
PQERRORS_TERSE::Number
(ro) (Static Properties)
PQERRORS_VERBOSE::Number
(ro) (Static Properties)
PQTRANS_ACTIVE::Number
(ro) (Static Properties)
PQTRANS_IDLE::Number
(ro) (Static Properties)
PQTRANS_INERROR::Number
(ro) (Static Properties)
PQTRANS_INTRANS::Number
(ro) (Static Properties)
PQTRANS_UNKNOWN::Number
(ro) (Static Properties)
SEEK_CUR::Number
(ro) (Static Properties)
SEEK_END::Number
(ro) (Static Properties)
SEEK_SET::Number
(ro) (Static Properties)
connDefaults | connectDb | connectStart | resStatus | unescapeBytea
Array connDefaults(void);
(Static Methods)
Retreives connection configuration defaults.
Array
An array of objects, each of which with properties describing the various options and their default.
PGConn connectDb(conninfo::String);
(Static Methods)
Connects to PostgreSQL.
PGConn
Connection handle to the server.
conninfo::String
Space separated keyword=value pair. Refer to 29.1. Database Connection Control Functions for more information.
SQLException
PGConn connectStart(conninfo::String);
(Static Methods)
Very similar to PG.connectDb()
but allows to launch the connection request asynchroneously. This means that the function returns immediately, but the application may poll on the internal descriptor and query the connection status for success or error.
PGConn
Connection handle.
conninfo::String
SQLException
String resStatus(code::Number);
(Static Methods)
Converts a PostgreSQL status code into a readable string.
String
String representation for the status code.
code::Number
String unescapeBytea(data::String);
(Static Methods)
Converts a string representation of binary data into binary data.
String
String containing binary bytes.
data::String
Escaped ASCII binary representation.
SQLException
Allows to cancel a query in progress. This object is obtained through a call to PGConn.getCancel()
.
Constructors | Static Properties | Static Methods | Properties | Methods
String|null cancel(void);
(Methods)
Cancels the in-progress query.
String|null
null
on success or a string with a reason message.
void freeCancel(void);
(Methods)
Frees the PGCancel
internal memory. The object becomes invalid.
Represents a connection instance to a PostgreSQL server. These objects are created by static methods of the PG
class.
Constructors | Static Properties | Static Methods | Properties | Methods
backendPid | connectPoll | consumeInput | db | errorMessage | escapeByteaConn | escapeStringConn | exec | execParams | execPrepared | finish | flush | getCancel | getCopyData | getResult | host | isBusy | isNonBlocking | jsExecParams | jsExecPrepared | jsPrepare | loClose | loCreat | loCreate | loExport | loImport | loOpen | loRead | loSeek | loTell | loUnlink | loWrite | makeEmptyPGResult | notifies | options | pass | port | prameterStatus | prepare | protocolVersion | putCopyData | putCopyEnd | reset | resetPoll | resetStart | sendPrepare | sendQuery | sendQueryParams | sendQueryPrepared | serverVersion | setErrorVerbosity | setNonBlocking | setNoticeProcessor | setNoticeReceiver | socket | status | trace | transactionStatus | tty | untrace | user
Number backendPid(void);
(Methods)
Obtain process ID of the backend server process which serves the connection.
Number
PID number.
Number connectPoll(void);
(Methods)
Obtain status of asynchroneous connection request.
Number
status Current status.
Boolean consumeInput(void);
(Methods)
Consume input from server if any. For use with asynchroneous mode functions.
Boolean
true
on success or false
on error, in which case PGConn.errorMessage()
may be consulted.
String db(void);
(Methods)
Returns name of database of connection.
String
String|null errorMessage(void);
(Methods)
Description message of last error.
String|null
String with message of last error generated by a call to a function, or null
.
String escapeByteaConn(string::String);
(Methods)
Escapes a binary string for use within an SQL command. It is recommended to generally use PGConn.execParams()
instead of using this in conjunction with PGConn.exec()
. Note that strings should not be escaped if using PGConn.execParams()
.
String
Resulting escaped string.
string::String
Binary string to escape.
SQLException
String escapeStringConn(string::String);
(Methods)
Escapes a string for use within an SQL command. It is recommended to generally use PGConn.execParams()
instead of using this in conjunction with PGConn.exec()
. Note that strings should not be escaped if using PGConn.execParams()
.
String
Resulting escaped string.
string::String
String to escape.
SQLException
PGResult exec(query::String);
(Methods)
Executes a command on the server. It is recommended to use PGConn.execParams()
instead.
PGResult
A results object.
query::String
SQL command to execute.
SQLException
PGResult execParams(command::String, nParams::Number, paramTypes::Array, paramValues::Array, paramLengths::Array, paramFormats::Array, resultFormat::Number);
(Methods)
Executes a query on the server in a safer way. Parameters are specified separately so that they are not vulnerable to SQL injection attacks. Those parameters no longer need to be escaped either.
PGResult
A results object.
command::String
SQL query to execute. Location of parameters should be marked using $<n>
where n
consists of a sequence number, corresponding to the order of the array arguments.
nParams::Number
Number of parameters, that is, length of the arrays paramTypes
, paramValues
, paramLengths
and paramFormats
. The array parameters may alternately be null
and this parameter 0
.
paramTypes::Array
Types to be assigned to parameters (OID) or null
, treating them as if they were untyped litteral strings. 0
in an array element also treats it as an untyped litteral.
paramValues::Array
Parameter values. Parameters which are null
are considered as the SQL NULL
.
paramLengths::Array
If there are binary parameters, specifies their length. Ignored for text parameters. May be null
if there are no binary parameters.
paramFormats::Array
Specifies if parameters are text (use 0
) or binary (use 1
). If null
, all parameters are considered to be in text format.
resultFormat::Number
0
to obtain results in text format, 1
in binary format.
SQLException
PGResult execPrepared(stmtName::String, nParams::Number, paramValues::Array, paramLengths::Array, paramFormats::Array, resultFormat::Number);
(Methods)
Like PGConn.exec()
but executes a prepared statement.
PGResult
stmtName::String
Prepared statement name to execute.
nParams::Number
paramValues::Array
paramLengths::Array
paramFormats::Array
resultFormat::Number
SQLException
void finish(void);
(Methods)
Closes the handle.
Number flush(void);
(Methods)
For use with asynchroneous functions. Attempts to write/flush any queued data.
Number
0
if success (or send queue empty), 1
poll again until writing can be done (connection must be non-blocking), -1
error.
PGCancel getCancel(void);
(Methods)
Obtain a cancellation object which may allow to cancel a pending command.
PGCancel
Object which may be used to cancel a pending command.
PGDataResult getCopyData(async::Boolean);
(Methods)
For use with SQL COPY TO STDOUT
command. Receive data.
PGDataResult
async::Boolean
Use asynchroneous (non-blocking) mode.
PGResult|null getResult(void);
(Methods)
Useful for asynchroneous mode functions. Normally call this function until null
is returned. PGResult.clear()
should be called to free these. Only blocks if a command is active and no response data has yet been read through PGConn.consumeInput()
.
PGResult|null
A PGResult
object or null
when no more are ready.
String host(void);
(Methods)
Returns host of the connection.
String
Boolean isBusy(void);
(Methods)
Boolean
true
if busy (PGConn.getResult() would block) or false
(it wouldn't block).
Boolean isNonBlocking(void);
(Methods)
Returns the mode of the connection.
Boolean
true
if non-blocking, false
if blocking.
PGResult jsExecParams(query::String, arguments::Array);
(Methods)
Simpler query function for JavaScript.
PGResult
query::String
arguments::Array
SQLException
PGResult jsExecPrepared(stmtName::String, arguments::Array);
(Methods)
Simpler function for JavaScript.
PGResult
stmtName::String
arguments::Array
SQLException
PGResult jsPrepare(stmtName::String, arguments::Array);
(Methods)
Simpler function for JavaScript.
PGResult
stmtName::String
arguments::Array
SQLException
Boolean loClose(descriptor::Number);
(Methods)
Close an open large object. Note that objects are automatically closed at the end of the transaction they were opened in.
Boolean
true
on success, false
on error.
descriptor::Number
Open object descriptor to close.
Number loCreat(mode::Number);
Deprecated (Methods)
Creates a large object. Use PGConn.create()
instead.
Number
Unique Oid
on success or PG.InvalidOid
on failure.
mode::Number
Currently unused, used to be the same as creat(2)
modes.
Number loCreate(oid::Number);
(Methods)
Creates a new large object.
Number
New Oid
or FD.InvalidOid
on error.
oid::Number
Oid
to use, or FD.InvalidOid
to let the system assign a new Oid
automatically.
Boolean loExport(oid::Number, path::String);
(Methods)
Exports data to a client-local file.
Boolean
true
on success or false
on error.
oid::Number
Oid
to export from.
path::String
Path to file to export to.
SecurityException
Write access to path
forbidden.
Number loImport(path::String);
(Methods)
Imports a client-local file.
Number
Unique Oid
or FD.InvalidOid
on error.
path::String
Path to file to import.
SecurityException
Access to path
forbidden.
Number loOpen(iod::Number, mode::Number);
(Methods)
Opens a large object. The object is automatically closed when the current transaction terminates. An object must previously have been created.
Number
descriptor Descriptor number representing the open file. Becomes invalid after a call to FDConn.close()
or once the transaction terminates. -1
on error.
iod::Number
Oid
of object to open.
mode::Number
Mode to open object in.
String loRead(descriptor::Number, size::Number);
(Methods)
Reads data from an open large object.
String
Data read. Empty string on EOF condition.
descriptor::Number
Open large object descriptor to read from.
size::Number
Maximum number of bytes to read.
SQLException
Error reading.
Number loSeek(descriptor::Number, offset::Number, whence::Number);
(Methods)
Seek to a position in the large object.
Number
New offset relative to the beginning of the object, or -1
on error.
descriptor::Number
Open large object descriptor.
offset::Number
Offset in bytes to seek to.
whence::Number
How to interpret offset
.
Number loTell(descriptor::Number);
(Methods)
Return the current position offset within the large object.
Number
Offset relative to start of the object, or a negative value on error.
descriptor::Number
Open large object descriptor.
Boolean loUnlink(oid::Number);
(Methods)
Deletes a large object.
Boolean
true
on success or false
on error.
oid::Number
Oid
of object to delete.
Number loWrite(descriptor::Number, data::String);
(Methods)
Write data to an open large object.
Number
Number of bytes written, or a negative value on error.
descriptor::Number
Open large object descriptor to write to.
data::String
Data to write.
PGResult makeEmptyPGResult(status::Number);
(Methods)
Creates an empty PGResult
object. Note that PGResult.clear
should be executed on the result object as well.
PGResult
New result object.
status::Number
Initial status to set for the object PG.PGRES_*
.
SQLException
PGNotifies|null notifies(void);
(Methods)
For use with SQL NOTIFY
and LISTEN
commands. Returns the next notification from list of unhandled notification messages received by the server.
PGNotifies|null
New object or null
if none left.
String options(void);
(Methods)
Returns options for the connection.
String
String pass(void);
(Methods)
Returns password of connection.
String
String port(void);
(Methods)
Returns port of the connection.
String
String|null prameterStatus(parameter::String);
(Methods)
Retreive status string of a server parameter.
String|null
Value of queried parameter or null
.
parameter::String
Name of parameter to query.
PGResult prepare(stmtName::String, query::String, nParams::Number, paramTypes::Array);
(Methods)
Prepares a statement for more effiicent subsequent calls.
PGResult
stmtName::String
Name of prepared statement.
query::String
SQL query.
nParams::Number
Number of parameters.
paramTypes::Array
Types of parameters by OID, or null
if nParams
is 0
.
SQLException
Number protocolVersion(void);
(Methods)
Returns the version of the server protocol.
Number
Version number.
Number putCopyData(data::String);
(Methods)
For use with SQL COPY FROM STDIN
. Sends data to the server.
Number
1
if data was sent, 0
if it wasn't sent because it would block (in non-blocking mode), or -1
on error.
data::String
Data to write.
Number putCopyEnd(errormsg::String|null);
(Methods)
Sends end-of-data indication to the server during COPY_IN
state.
Number
1
termination data was sent, 0
not sent as it would block (in non-blocking mode) or -1
on error.
errormsg::String|null
If null
, end normally. Otherwise, error message to supply.
void reset(void);
(Methods)
Attempts to reset and re-establish connection.
Number resetPoll(void);
(Methods)
Retreive status of non-blocking reset polling.
Number
status Current status.
Boolean resetStart(void);
(Methods)
Attempts to reset and re-establish connection asynchroneously.
Boolean
true
on success; false
otherwise.
Boolean sendPrepare(stmtName::String, query::String, nParams::Number, paramTypes::Array);
(Methods)
Like PGConn.prepare()
but is asynchroneous.
Boolean
true
on success or false
on failure.
stmtName::String
query::String
nParams::Number
paramTypes::Array
Boolean sendQuery(*::String);
(Methods)
Analogous to PGConn.exec()
yet sends the request asynchroneously.
Boolean
true
on success or false
on failure. Status of the request should still be monitored and polling done.
*::String
SQL query to execute.
PGResult sendQueryParams(command::String, nParams::Number, paramTypes::Array, paramValues::Array, paramLengths::Array, paramFormats::Array, resultFormat::Number);
(Methods)
Equivalent to PGConn.execParams
but sends the request in asynchroneous mode.
PGResult
command::String
SQL query to execute. Location of parameters should be marked using $<n>
where n
consists of a sequence number, corresponding to the order of the array arguments.
nParams::Number
Number of parameters, that is, length of the arrays paramTypes
, paramValues
, paramLengths
and paramFormats
. The array parameters may alternately be null
and this parameter 0
.
paramTypes::Array
Types to be assigned to parameters (OID) or null
, treating them as if they were untyped litteral strings. 0
in an array element also treats it as an untyped litteral.
paramValues::Array
Parameter values. Parameters which are null
are considered as the SQL NULL
.
paramLengths::Array
If there are binary parameters, specifies their length. Ignored for text parameters. May be null
if there are no binary parameters.
paramFormats::Array
Specifies if parameters are text (use 0
) or binary (use 1
). If null
, all parameters are considered to be in text format.
resultFormat::Number
0
to obtain results in text format, 1
in binary format.
SQLException
Boolean sendQueryPrepared(stmtName::String, nParams::Number, paramValues::Array, paramLengths::Array, paramFormats::Array, resultFormat::Number);
(Methods)
Like PGConn.execPrepared()
but asynchroneously.
Boolean
true
on success, false
on failure.
stmtName::String
Prepared statement name to execute.
nParams::Number
paramValues::Array
paramLengths::Array
paramFormats::Array
resultFormat::Number
Number serverVersion(void);
(Methods)
Returns the version of the server.
Number
Version number.
Number setErrorVerbosity(verbosity::Number);
(Methods)
Sets error messages verbosity.
Number
Previous verbosity level.
verbosity::Number
Verbosity level to set.
Boolean setNonBlocking(nonblock::Boolean);
(Methods)
Sets the blocking/non-blocking mode of the connection, for use with asynchroneous functions.
Boolean
true
on success, false
on error.
nonblock::Boolean
true
for non-blocking, false
for blocking.
Function|null setNoticeProcessor(function::Function, udata::Object|null);
(Methods)
Sets a custom notice processor function and/or obtain information about the current one.
Function|null
Old notice processor function, if any.
function::Function
Function to be called when a notice is received. Its signature should be as follows:
void function(udata::Object|null, msg::String);
udata::Object|null
Optional custom user data object to pass to the function or null
.
Function|null setNoticeReceiver(function::Function, udata::Object|null);
(Methods)
Sets a custom notice receiver function and/or obtain information about the current one.
Function|null
Old notice receiver function, if any.
function::Function
Function to be called when a notice is received. Its signature should be as follows:
void function(udata::Object|null, res::PGResult);
udata::Object|null
Optional custom user data object to pass to the function or null
.
Number socket(void);
(Methods)
Obtain unix descriptor of the socket associated with connection. This is useful for polling when using asynchroneous functions.
Number
Descriptor number.
Number status(void);
(Methods)
Returns numeric status code for the connection state.
Number
Status code (PG.CONNECTION_*
).
void trace(handle::File);
(Methods)
Trace verbosely to specified File
handle object.
handle::File
File
handle to to write log entries to.
Number transactionStatus(void);
(Methods)
Returns numeric status code of the current transaction state.
Number
Status code (PG.PQTRANS_*
).
String tty(void);
(Methods)
Returns tty of the connection.
String
void untrace(void);
(Methods)
Stop verbose tracing.
String user(void);
(Methods)
Returns user of connection.
String
Not a class per se, but an object returned by PGConn.getCopyData
.
Constructors | Static Properties | Static Methods | Properties | Methods
data::String|null
(ro) (Properties)
Received data.
result::Number
(ro) (Properties)
Return code. Number of bytes received (always > 0
), 0
if operation would block (non-blocking async mode), -1
copy is fully done or -2
on error.
Not an actual class per se, used to describe the object returned by PGConn.notifies()
.
Constructors | Static Properties | Static Methods | Properties | Methods
be_pid::Number
(ro) (Properties)
Process ID of notifying server process.
extra::String
(ro) (Properties)
Notification parameter.
relname::String
(ro) (Properties)
Notification condition name.
When invoking PGResult.print()
, an object of this type must be supplied, and its properties filled for the printing configuration.
Constructors | Static Properties | Static Methods | Properties | Methods
align | caption | expanded | fieldName | fieldSep | header | html3 | pager | standard | tableOpt
align::Boolean
(rw) (Properties)
caption::String
(rw) (Properties)
expanded::Boolean
(rw) (Properties)
fieldName::Array
(rw) (Properties)
An array of strings, one string per field name.
fieldSep::String
(rw) (Properties)
header::Boolean
(rw) (Properties)
html3::Boolean
(rw) (Properties)
pager::Boolean
(rw) (Properties)
standard::Boolean
(rw) (Properties)
tableOpt::String
(rw) (Properties)
This class is used to represent results of SQL queries made to a PostgreSQL server, via an open PGConn
object.
Constructors | Static Properties | Static Methods | Properties | Methods
binaryTuples | clear | cmdStatus | cmdTuples | fFormat | fMod | fName | fNumber | fSize | fTable | fTableCol | fType | getIsNull | getLength | getValue | jsGetResults | nFields | nTuples | oidValue | print | resultErrorField | resultErrorMessage | resultStatus
Number binaryTuples(void);
Deprecated (Methods)
Obtain type of result data. This function is deprecated as every column may be in its own format. Use PGResult.fFormat()
instead.
Number
0
if text or 1
if binary.
void clear(void);
(Methods)
Clears memory associated with the specified results object.
String cmdStatus(void);
(Methods)
Obtain command status tag string.
String
Tag string.
String cmdTuples(void);
(Methods)
Obtain number of rows affected by command.
String
rows Number of affected rows.
Number fFormat(col::Number);
(Methods)
Obtain format code for a given column.
Number
Format code. 0
means text representation, 1
binary representation. Other codes reserved for future definitions.
col::Number
Column number, starting at 0
.
Number fMod(col::Number);
(Methods)
Obtain type modifier for the given column number. This for instance could be the number of decimals of a decimal type.
Number
Modifyer number or -1
for no information.
col::Number
Column number, starting at 0
.
String fName(field::Number);
(Methods)
Obtrain field name.
String
Field name.
field::Number
Field number to obtain name of.
SQLException
Field number out of range.
Number fNumber(fieldname::String);
(Methods)
Obtain field number associated with field name.
Number
Field number or -1
if field does not exist.
fieldname::String
Name of field.
Number fSize(col::Number);
(Methods)
Obtain size in bytes for a given column. Note that one should instead rely on the size returned by PGResult.getLength()
for fields.
Number
Size in bytes, or a negative value if variable-length.
col::Number
Column number, starting at 0
.
Number fTable(fieldnumber::Number);
(Methods)
Obtain Oid
of table for a given result column.
Number
Oid
or PG.InvalidOid
on error.
fieldnumber::Number
Field number.
Number fTableCol(col::Number);
(Methods)
Obtain table's column number making up the specified result column.
Number
Column number of 0
if col
is out of range.
col::Number
Column number, starting at 0
.
Number fType(col::Number);
(Methods)
Obtain data type for a given column.
Number
Oid
of type.
col::Number
Column number, starting at 0
Boolean getIsNull(row::Number, col::Number);
(Methods)
Tests given field for SQL NULL
value.
Boolean
true
if NULL
or false
otherwise.
row::Number
Row number.
col::Number
Column number.
Number getLength(row::Number, col::Number);
(Methods)
Obtain length of field value in bytes.
Number
Number of bytes.
row::Number
Row number starting at 0
.
col::Number
Column number starting at 0
.
String|null getValue(row::Number, column::Number);
(Methods)
Obtain single given field of given row.
String|null
null
for SQL NULL
value or field content.
row::Number
Row.
column::Number
Column.
SQLException
Array jsGetResults(void);
(Methods)
Obtain a JavaScript array of the result set.
Array
Results array.
SQLException
Number nFields(void);
(Methods)
Obtain number of columns.
Number
Number of columns.
Number nTuples(void);
(Methods)
Obtain number of rows.
Number
Number of rows.
Number oidValue(void);
(Methods)
Obtain Oid
of last single inserted row if any.
Number
Oid
or PG.InvalidOid
.
void print(fh::File, conf::PGPrintOpt);
(Methods)
Prints the result set.
fh::File
File handle to write to.
conf::PGPrintOpt
Printing configuration.
String resultErrorField(fieldcode::Number);
(Methods)
Obtain an individual field of an error report.
String
Field.
fieldcode::Number
Field code (PG.PG_DIAG_*
).
String resultErrorMessage(void);
(Methods)
Obtain error message associated with command.
String
Error message or an empty string if no error.
Number resultStatus(void);
(Methods)
Obtain associated status result code.
Number
code PG.PGRES_*
code.
Implements a general purpose receive queue buffer. Especially useful for use with non-blocking sockets and polling events. Faster than custom implementations in JavaScript using strings, and uses half the memory.
Constructors | Static Properties | Static Methods | Properties | Methods
void RecvQ(fd::FD, size::Number);
(Constructors)
fd::FD
FD
object to wrap.
size::Number
Buffer size.
EMPTY | EOF | ERROR | FULL | TOOLONG
EMPTY::Number
(ro) (Static Properties)
The buffer is empty.
EOF::Number
(ro) (Static Properties)
End Of File event was detected.
ERROR::Number
(ro) (Static Properties)
An error occurred.
FULL::Number
(ro) (Static Properties)
The buffer is full.
TOOLONG::Number
(ro) (Static Properties)
Line longer than expected.
length::Number
(ro) (Properties)
Number of bytes currently in buffer
purge | read | readLine | substr
void purge(void);
(Methods)
Discards any pending data from the read buffer.
String|Number read(void);
(Methods)
Reads data from buffer if any.
String|Number
Returns available data in a String
or an error number. Note that the ===
or !==
comparision operators should be used with explicit checks against error conditions, or the return type must be tested to be a String
using typeof
.
String|Number readLine(size::Number);
(Methods)
Reads a line from the input buffer if possible, and strips any terminating '\n'
or "\r\n"
. The application should first invoke the RecvQ.read()
method and then in a loop can call this function until no more lines can be found in the buffer, in which case any remaining partial line will be saved to hopefully be completed at the next RecvQ.read()
method call.
String|Number
A String
with the line is returned if possible, or a Number
with an error number. Note that because a String
's contents could be evaluated as the same numbers which are returned on error conditions by ==
, it is important to use the strict ===
or !==
operators against error numbers to detect these conditions reliably.
size::Number
The maximum allowed line buffer size to use.
String substr(offset::Number, length::Number);
(Methods)
Returns a substring from the contents of the read buffer without purging the buffer. Also see the length property to know available bounds.
String
Substring.
offset::Number
Starting offset in the buffer.
length::Number
Number of bytes to return from offset.
String toString(void);
(Methods)
Returns the whole contents of the read buffer. Does not purge the buffer.
String
Contents of the pending read buffer (may be empty).
General purpose send queue buffer. Especially useful for use with non-blocking sockets and polling events. Faster than a JavaScript implementation using strings, and uses half the memory.
Constructors | Static Properties | Static Methods | Properties | Methods
void SendQ(fd::FD, size::Number);
(Constructors)
fd::FD
FD
object to wrap.
size::Number
Buffer size.
EMPTY::Number
(ro) (Static Properties)
Buffer is empty.
ERROR::Number
(ro) (Static Properties)
An error occurred.
FULL::Number
(ro) (Static Properties)
Buffer is full.
length::Number
(ro) (Properties)
Number of bytes currently in buffer.
Number flush(void);
(Methods)
Attempt to flush buffer, writing it to the wrapped FD
. To be safe, normally the application will ensure that all data has been flushed before queueing more data or closing the client connection.
Number
Number of bytes written. If all queued bytes have been written, SendQ.EMPTY
is returned. On error, SendQ.ERROR
is returned (writing error, the FD
object's errno
property will hold more information).
Number write(data::String);
(Methods)
Queue data in the buffer.
Number
Number of bytes queued or SendQ.FULL
if there is no more room and the buffer must be flushed (or if the data to write exceeds the buffer size).
data::String
Data to write to the buffer.
This class has no constructors, and is in fact simply an unclassed Object
. This object is returned by FD.fstat()
and FS.stat()
, FS.lstat()
. XXX
A real Stat class should probably be created, with stat-related constants set as static properties of it. Because they are now static properties of FD, yet FS also creates Stat objects.
Constructors | Static Properties | Static Methods | Properties | Methods
st_atime | st_blksize | st_blocks | st_ctime | st_dev | st_flags | st_gen | st_gid | st_ino | st_mode | st_mtime | st_nlink | st_rdev | st_size | st_uid
st_atime::Number
(ro) (Properties)
Last access time.
st_blksize::Number
(ro) (Properties)
Optimal block size for this FS.
st_blocks::Number
(ro) (Properties)
Blocks allocated for file.
st_ctime::Number
(ro) (Properties)
Last file status change time.
st_dev::Number
(ro) (Properties)
Device containing the file.
st_flags::Number
(ro) (Properties)
User-defined flags for file.
st_gen::Number
(ro) (Properties)
File generation number.
st_gid::Number
(ro) (Properties)
Group-id of owner.
st_ino::Number
(ro) (Properties)
File's serial number.
st_mode::Number
(ro) (Properties)
File's mode (protection and mode).
st_mtime::Number
(ro) (Properties)
Last modification time.
st_nlink::Number
(ro) (Properties)
Number of hard links to file.
st_rdev::Number
(ro) (Properties)
Device type for special files.
st_size::Number
(ro) (Properties)
File size, in bytes.
st_uid::Number
(ro) (Properties)
User-id of owner.
Provides access to the syslog(3)
facilities.
Constructors | Static Properties | Static Methods | Properties | Methods
LOG_ALERT | LOG_AUTH | LOG_AUTHPRIV | LOG_CONS | LOG_CRIT | LOG_CRON | LOG_DAEMON | LOG_DEBUG | LOG_EMERG | LOG_ERR | LOG_FTP | LOG_INFO | LOG_KERN | LOG_LOCAL0 | LOG_LOCAL1 | LOG_LOCAL2 | LOG_LOCAL3 | LOG_LOCAL4 | LOG_LOCAL5 | LOG_LOCAL6 | LOG_LOCAL7 | LOG_LPR | LOG_MAIL | LOG_NDELAY | LOG_NEWS | LOG_NOTICE | LOG_PERROR | LOG_PID | LOG_SYSLOG | LOG_USER | LOG_UUCP | LOG_WARNING
LOG_ALERT::Number
(ro) (Static Properties)
LOG_AUTH::Number
(ro) (Static Properties)
LOG_AUTHPRIV::Number
(ro) (Static Properties)
LOG_CONS::Number
(ro) (Static Properties)
LOG_CRIT::Number
(ro) (Static Properties)
LOG_CRON::Number
(ro) (Static Properties)
LOG_DAEMON::Number
(ro) (Static Properties)
LOG_DEBUG::Number
(ro) (Static Properties)
LOG_EMERG::Number
(ro) (Static Properties)
LOG_ERR::Number
(ro) (Static Properties)
LOG_FTP::Number
(ro) (Static Properties)
LOG_INFO::Number
(ro) (Static Properties)
LOG_KERN::Number
(ro) (Static Properties)
LOG_LOCAL0::Number
(ro) (Static Properties)
LOG_LOCAL1::Number
(ro) (Static Properties)
LOG_LOCAL2::Number
(ro) (Static Properties)
LOG_LOCAL3::Number
(ro) (Static Properties)
LOG_LOCAL4::Number
(ro) (Static Properties)
LOG_LOCAL5::Number
(ro) (Static Properties)
LOG_LOCAL6::Number
(ro) (Static Properties)
LOG_LOCAL7::Number
(ro) (Static Properties)
LOG_LPR::Number
(ro) (Static Properties)
LOG_MAIL::Number
(ro) (Static Properties)
LOG_NDELAY::Number
(ro) (Static Properties)
LOG_NEWS::Number
(ro) (Static Properties)
LOG_NOTICE::Number
(ro) (Static Properties)
LOG_PERROR::Number
(ro) (Static Properties)
LOG_PID::Number
(ro) (Static Properties)
LOG_SYSLOG::Number
(ro) (Static Properties)
LOG_USER::Number
(ro) (Static Properties)
LOG_UUCP::Number
(ro) (Static Properties)
LOG_WARNING::Number
(ro) (Static Properties)
close | log | mask | maskUpto | open | setMask
void close(void);
(Static Methods)
Unconfigures the logging facility.
void log(priority::Number, message::String);
(Static Methods)
Add a new log entry.
priority::Number
Priority to use for message.
message::String
Message to log.
Number mask(parameter::Number);
(Static Methods)
Wrapper around the LOG_MASK()
macro. For use with Syslog.setMask()
.
Number
parameter::Number
Number maskUpto(parameter::Number);
(Static Methods)
Wrapper around the LOG_UPTO()
macro. For use with Syslog.setMask()
.
Number
parameter::Number
void open(name::String, logopt::Number, facility::Number);
(Static Methods)
Configure the system logging facility for this process.
name::String
Application name to display in logs.
logopt::Number
Options.
facility::Number
Logging facility to use.
Number setMask(mask::Number);
(Static Methods)
Change logging mask.
Number
Previous mask.
mask::Number
New mask to set.
Generated by |