In that ModernBill is designed to automate and control other pieces of a complete system, it relies on its ability to network, or interface with remote systems. To satisfy this need, ModernBill has many networking libraries:
Curl classProvides an object-oriented interface to the system cURL library (libcurl) via:
curl extension.curl command-line utility.Nearly all modules use this for HTTP calls.
Files of interest:
/lib-mbapi/include/curl/curl.phpProvides the Curl class itself.
/app-lib/include/config/config.phpConfiguration options in the section labelled cURL SETTINGS.
Provides an object-oriented interface to the System-V Inter-Process Communication functions provided by the sysvsem, sysvshm, and sysvmsg PHP extensions.
Files of interest:
/lib-tk/include/io/ipc.phpProvides the following classes:
struct msg_perm as QueuePermissionsstruct msqid_ds as QueueStatestruct msgp as Messageint msqid as MessageQueueint semid as Semaphoreint shmid as SharedMemoryint shmid and int semid as ProtectedSharedMemoryProvides the following functions:
get_ipc_key()Provides a unique identifier for initializing an IPC resource.
NamedPipe classProvides an object-oriented interface to non-blocking I/O operations over any kind of pipe, including named pipes (Unix FIFO files). Its main design feature is that it safely waits for broken pipes to be reestablished. This is useful for command-line integrations with fast, persistent, named connections.
Files of interest:
/lib-tk/include/io/fifo.phpProvides the NamedPipe class.
/app-modernbill-api/mbapi.phpImplements an interface to the MBAPI on top of the NamedPipe class.
/app-modernbill-api/mbapilib.*Libraries which glue various languages to the MBAPI.
Provides an elaborate system for multiplexing I/O tasks, or any kind of task, based on a real-time scheduler and an integrated I/O polling framework. Built on top of this are HTTP and Whois clients.
Files of interest...
Portability functions:
/lib-tk/include/io/time.phpProvides portable microtime_float() function.
/lib-tk/include/io/identity.phpProvides portable identity() function and ObjectSet class, providing a way to hash by object instance.
Data structures:
/lib-tk/include/io/buffer.phpProvides Buffer class, providing an easy interface to common string operations.
/lib-tk/include/io/queue.phpProvides Queue and QueueItem classes, for providing an object queue.
/lib-tk/include/io/tree.phpProvides Tree and Earth classes, and a plant() factory function, implementing a binary search tree.
/lib-tk/include/io/flags.phpProvides Flags and BitMask classes, and the registerFlags(), registerFlagSet, and registerFlagOptions() functions, for providing easy ways of viewing and manipulating bitmasks, for making debugging easier.
/lib-tk/include/io/timeline.phpProvides TimePoint and TimeEvent classes, a queue for events at a particular point in time.
Provides TimeRange and TimeLine classes, where the time-line is a time-range containing a tree of time-points containing event-queues.
/lib-tk/include/io/task_schedule.phpProvides Schedule and ScheduleEvent classes, a TimeLine for handling TimeEvents associated with a Task and a task-event: "start", "out", or "stop".
Provides Task class, a base for implementing time-triggered methods which operate on a target. Each target is represented by a queue of tasks waiting to do work on the target, provided by TaskQueue and TaskQueueItem, which contains a reference back to the Task. As task-events are triggered, they move from the schedule to the task; specifically, from the task-event-queue at the time-point in the schedule to the task-queue on the target.
Provides MetaTask and EventCallback classes, a base for linking stages of tasks together. MetaTask uses EventCallbacks to tie the completion of one sub-task to the start of another.
Provides TaskPollRegistration, an interface for polling the schedule for task events, for triggering actions external to the operation of a task, based on an event internal to the operation of a task.
Resource structures:
/lib-tk/include/io/stream.phpProvides Pipe class, a base for InPipe and OutPipe, paired inside a Stream base for ProcStream and SocketStream.
PipeInPipeOutPipeStreamProcStreamstdin and stdout of a shell command.SocketStream/lib-tk/include/io/poll.phpPollerProvides a poll(2)-style interface to the stream_select() PHP function, which actually uses the select(2) system call. This interface was chosen for future support for epoll(2) and kqueue(2).
PollRegistrationRepresents a stream associated with a network availability event. These are registered or unregistered with the class Poller.
BitRefsUsed by Poller to count references to registered events. Events can be registered in a nested fashion: events can be registered any number of times, and are only unregistered when unregistered as many times as registered.
Operational structures:
/lib-tk/include/io/realtime.phpRealTimeStreamRepresents a scheduler associated with a stream, and satisfies network availability events with I/O operations. A stream can only be managed by one scheduler at a time.
RealTimePipeBufferAn extension of TaskQueue associated with a RealTimeStream and a Buffer.
RealTimeInPipeBufferAn extension of RealTimePipeBuffer which provides a method for reading from the stream into a buffer.
RealTimeOutPipeBufferAn extension of RealTimePipeBuffer which provides a method for writing to the stream from a buffer.
RealTimeIOAn extension of Schedule which waits on network availability via Poller, firing events on RealTimeStream task targets.
RealTimeTaskAn extension of Task which initializes the I/O task-queue on the target, and registers network availability events on the RealTimeIO's internal Poller.
RealTimeInputTask, RT_INPUTAn extension of RealTimeTask which provides a base for reading input from a stream.
RealTimeOutputTask, RT_OUTPUTAn extension of RealTimeTask which provides a base for writing output to a stream.
RealTimeDelimitedInputTaskAn extension of RealTimeInputTask which provides a base for reading input from a stream until a delimiter is reached.
RealTimeReadlineTask, RT_READLINEAn extension of RealTimeDelimitedInputTask which sets the delimiter to "\n", a newline.
RealTimeMBAPIResponseTaskAn extension of RealTimeDelimitedInputTask which sets the delimiter to "<?mb end ?>", the MBAPI command delimiter in the MBAPI stream protocol.
RealTimeHTTPResponseHeaderTaskAn extension of RealTimeDelimitedInputTask which sets the delimiter to "\r\n\r\n" (CRNL CRNL).
RealTimeMatchInputTask, RT_MATCHAn extension of RealTimeInputTask which looks for a pattern until EOF.
/lib-tk/include/io/http.phpProvides an HTTP 1.1 compliant client. It is implemented as a meta-task which controls the flow of underlying input and output tasks. Classes representing components of HTTP requests and responses are also provided.
Public request and response structures:
HTTPRequestLineRepresents an HTTP request line comprised of the following:
HTTPURI uriHTTPResponseLineRepresents an HTTP response line comprised of the following:
HTTPDocumentRepresents binary data and its MIME type:
URLArgRepresents a single URL argument:
URLArgsRepresents a list of URL arguments:
HTTPURIRepresents an HTTP URI comprised of the following:
URLArgs argsHTTPURLRepresents an HTTP URL comprised of the following:
HTTPURI uriHTTPClientTaskProvides a meta-task which implements an HTTP client.
Operational structures:
HTTPHeadersProvides representation and serialization for HTTP headers.
/lib-tk/include/io/whois.phpProvides a whois client with support for:
Public request structures:
WhoisConditionA pattern match condition for evaluating a whois response status:
WhoisServiceDescribes a whois service:
BitMask("whois protocol") protocolWhoisCondition available_conditionWhoisCondition reject_conditionAsyncWhoisUsing RealTimeIO and WhoisTarget, provides asynchronous whois lookups:
WhoisService whois_serviceTRUEFALSENULLOperational structures:
WhoisTargetProvides a target for whois meta-tasks which yields the underlying target for sub-tasks, and request information.
WhoisService whois_serviceWhoisTaskAn extension of MetaTask which implements whois and whois2 clients.
HTTPWhoisTaskAn extension of HTTPClientTask which implements whois over HTTP and HTTPS.