blob: 5b68ead83e25bec30d7419ddeff428447f200fd8 [file] [log] [blame]
Alexandre Lision8af73cb2013-12-10 14:11:20 -05001/* $Id$ */
2/*
3 * Copyright (C) 2010 Teluu Inc. (http://www.teluu.com)
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19#ifndef __PJLIB_UTIL_CLI_CONSOLE_H__
20#define __PJLIB_UTIL_CLI_CONSOLE_H__
21
22/**
23 * @file cli_console.h
24 * @brief Command Line Interface Console Front End API
25 */
26
27#include <pjlib-util/cli_imp.h>
28
29
30PJ_BEGIN_DECL
31
32/**
33 * @ingroup PJLIB_UTIL_CLI_IMP
34 * @{
35 *
36 */
37
38
39/**
40 * This structure contains various options for CLI console front-end.
41 * Application must call pj_cli_console_cfg_default() to initialize
42 * this structure with its default values.
43 */
44typedef struct pj_cli_console_cfg
45{
46 /**
47 * Default log verbosity level for the session.
48 *
49 * Default value: PJ_CLI_CONSOLE_LOG_LEVEL
50 */
51 int log_level;
52
53 /**
54 * Specify text message as a prompt string to user.
55 *
56 * Default: empty
57 */
58 pj_str_t prompt_str;
59
60 /**
61 * Specify the command to quit the application.
62 *
63 * Default: empty
64 */
65 pj_str_t quit_command;
66
67} pj_cli_console_cfg;
68
69
70/**
71 * Initialize pj_cli_console_cfg with its default values.
72 *
73 * @param param The structure to be initialized.
74 */
75PJ_DECL(void) pj_cli_console_cfg_default(pj_cli_console_cfg *param);
76
77
78/**
79 * Create a console front-end for the specified CLI application, and return
80 * the only session instance for the console front end. On Windows operating
81 * system, this may open a new console window.
82 *
83 * @param cli The CLI application instance.
84 * @param param Optional console CLI parameters. If this value is
85 * NULL, default parameters will be used.
86 * @param p_sess Pointer to receive the session instance for the
87 * console front end.
88 * @param p_fe Optional pointer to receive the front-end instance
89 * of the console front-end just created.
90 *
91 * @return PJ_SUCCESS on success, or the appropriate error code.
92 */
93PJ_DECL(pj_status_t) pj_cli_console_create(pj_cli_t *cli,
94 const pj_cli_console_cfg *param,
95 pj_cli_sess **p_sess,
96 pj_cli_front_end **p_fe);
97
98/**
99 * Retrieve a cmdline from console stdin and process the input accordingly.
100 *
101 * @param sess The CLI session.
102 * @param buf Pointer to receive the buffer.
103 * @param maxlen Maximum length to read.
104 *
105 * @return PJ_SUCCESS if an input was read
106 */
107PJ_DECL(pj_status_t) pj_cli_console_process(pj_cli_sess *sess,
108 char *buf,
109 unsigned maxlen);
110
111/**
112 * @}
113 */
114
115PJ_END_DECL
116
117#endif /* __PJLIB_UTIL_CLI_CONSOLE_H__ */