Group PJLIB_UTIL_CLI_IMP

group PJLIB_UTIL_CLI_IMP

Defines

PJ_CLI_CONSOLE_LOG_LEVEL

Default log level for console sessions.

PJ_CLI_TELNET_LOG_LEVEL

Default log level for telnet sessions.

PJ_CLI_TELNET_PORT

Default port number for telnet daemon.

Enums

enum pj_cli_front_end_type

This enumeration specifies front end types.

Values:

enumerator PJ_CLI_CONSOLE_FRONT_END

Console front end.

enumerator PJ_CLI_TELNET_FRONT_END

Telnet front end.

enumerator PJ_CLI_HTTP_FRONT_END

HTTP front end.

enumerator PJ_CLI_GUI_FRONT_END

GUI front end.

struct pj_cli_console_cfg
#include <cli_console.h>

This structure contains various options for CLI console front-end. Application must call pj_cli_console_cfg_default() to initialize this structure with its default values.

Public Members

int log_level

Default log verbosity level for the session.

Default value: PJ_CLI_CONSOLE_LOG_LEVEL

pj_str_t prompt_str

Specify text message as a prompt string to user.

Default: empty

pj_str_t quit_command

Specify the command to quit the application.

Default: empty

struct pj_cli_front_end_op
#include <cli_imp.h>

Front end operations. Only the CLI should call these functions directly.

Public Members

void (*on_write_log)(pj_cli_front_end *fe, int level, const char *data, pj_size_t len)

Callback to write a log message to the appropriate sessions belonging to this front end. The front end would only send the log message to the session if the session’s log verbosity level is greater than the level of this log message.

Param fe:

The front end.

Param level:

Verbosity level of this message message.

Param data:

The message itself.

Param len:

Length of this message.

void (*on_quit)(pj_cli_front_end *fe, pj_cli_sess *req)

Callback to be called when the application is quitting, to signal the front-end to end its main loop or any currently blocking functions, if any.

Param fe:

The front end.

Param req:

The session which requested the application quit.

void (*on_destroy)(pj_cli_front_end *fe)

Callback to be called to close and self destroy the front-end. This must also close any active sessions created by this front-ends.

Param fe:

The front end.

struct pj_cli_front_end
#include <cli_imp.h>

This structure describes common properties of CLI front-ends. A front- end is a mean to interact with end user, for example the CLI application may interact with console, telnet, web, or even a GUI.

Each end user’s interaction will create an instance of pj_cli_sess.

Application instantiates the front end by calling the appropriate function to instantiate them.

Forward declaration for CLI front-end.

Public Functions

PJ_DECL_LIST_MEMBER(struct pj_cli_front_end)

Linked list members

Public Members

pj_cli_front_end_type type

Front end type.

pj_cli_t *cli

The CLI application.

pj_cli_front_end_op *op

Front end operations.

struct pj_cli_sess_op
#include <cli_imp.h>

Session operations.

Public Members

void (*destroy)(pj_cli_sess *sess)

Callback to be called to close and self destroy the session.

Param sess:

The session to destroy.

struct pj_cli_sess
#include <cli_imp.h>

This structure describes common properties of a CLI session. A CLI session is the interaction of an end user to the CLI application via a specific renderer, where the renderer can be console, telnet, web, or a GUI app for mobile. A session is created by its renderer, and it’s creation procedures vary among renderer (for example, a telnet session is created when the end user connects to the application, while a console session is always instantiated once the program is run).

Forward declaration for pj_cli_sess, which will be declared in cli_imp.h.

Public Functions

PJ_DECL_LIST_MEMBER(struct pj_cli_sess)

Linked list members

Public Members

pj_cli_front_end *fe

Pointer to the front-end instance which created this session.

pj_cli_sess_op *op

Session operations.

pj_str_t info

Text containing session info, which is filled by the renderer when the session is created.

int log_level

Log verbosity of this session.

struct pj_cli_telnet_info
#include <cli_telnet.h>

This structure contains the information about the telnet. Application will get updated information each time the telnet is started/ restarted.

Public Members

pj_str_t ip_address

The telnet’s ip address.

pj_uint16_t port

The telnet’s port number.

char buf_[32]

Internal buffer for IP address