Ignore:
Timestamp:
Jun 30, 2010 5:29:59 AM (14 years ago)
Author:
ming
Message:

Implemented CLI (re #1098)

  • pjlib-util:
    • implement telnet CLI
  • pjsip-apps/samples:
    • sample CLI demo application
  • build:
    • VS6 and Makefile
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/projects/cli/pjlib-util/include/pjlib-util/cli.h

    r3211 r3231  
    3838 
    3939/** 
    40  * Maximum length of command buffer. 
    41  */ 
    42 #ifndef PJ_CLI_MAX_CMDBUF 
    43 #   define PJ_CLI_MAX_CMDBUF            120 
    44 #endif 
    45  
    46 /** 
    47  * Maximum command arguments. 
    48  */ 
    49 #ifndef PJ_CLI_MAX_ARGS 
    50 #   define PJ_CLI_MAX_ARGS              8 
    51 #endif 
    52  
    53 /** 
    54  * Maximum short name version (shortcuts) for a command. 
    55  */ 
    56 #ifndef PJ_CLI_MAX_SHORTCUTS 
    57 #   define PJ_CLI_MAX_SHORTCUTS         4 
    58 #endif 
    59  
    60 /* 
    61  *  New error constants (note: to be placed in errno.h with new values) 
    62  */ 
    63 /** 
    64  * @hideinitializer 
    65  * End the current session. This is a special error code returned by 
    66  * pj_cli_exec() to indicate that "exit" or equivalent command has been 
    67  * called to end the current session. 
    68  */ 
    69 #define PJ_CLI_EEXIT                    -101 
    70 /** 
    71  * @hideinitializer 
    72  * A required CLI argument is not specified. 
    73  */ 
    74 #define PJ_CLI_EMISSINGARG              -104 
    75  /** 
    76  * @hideinitializer 
    77  * Too many CLI arguments. 
    78  */ 
    79 #define PJ_CLI_ETOOMANYARGS             -105 
    80 /** 
    81  * @hideinitializer 
    82  * Invalid CLI argument. Typically this is caused by extra characters 
    83  * specified in the command line which does not match any arguments. 
    84  */ 
    85 #define PJ_CLI_EINVARG                  -106 
    86 /** 
    87  * @hideinitializer 
    88  * CLI command with the specified name already exist. 
    89  */ 
    90 #define PJ_CLI_EBADNAME                 -107 
    91  
    92 /** 
    9340 * This opaque structure represents a CLI application. A CLI application is 
    9441 * the root placeholder of other CLI objects. In an application, one (and 
     
    14693     */ 
    14794    pj_pool_factory *pf; 
    148  
    149     /** 
    150      * Specify whether only exact matching command will be executed. If 
    151      * PJ_FALSE, the framework will accept any unique abbreviations of 
    152      * the command. Please see the description of pj_cli_parse() function 
    153      * for more info. 
    154      * 
    155      * Default: PJ_FALSE 
    156      */ 
    157     pj_bool_t exact_cmd; 
    15895 
    15996} pj_cli_cfg; 
     
    383320 */ 
    384321PJ_DECL(void) pj_cli_exec_info_default(pj_cli_exec_info *param); 
     322 
     323/** 
     324 * Write a log message to the CLI application. The CLI application 
     325 * will send the log message to all the registered front-ends. 
     326 * 
     327 * @param cli           The CLI application instance. 
     328 * @param level         Verbosity level of this message message. 
     329 * @param buffer        The message itself. 
     330 * @param len           Length of this message. 
     331 */ 
     332PJ_DECL(void) pj_cli_write_log(pj_cli_t *cli, 
     333                               int level, 
     334                               const char *buffer, 
     335                               int len); 
    385336 
    386337/** 
     
    498449 * registered in the CLI application. 
    499450 * 
    500  * By default, a command may be matched by any shorter abbreviations of the 
    501  * command that uniquely identify the command. For example, suppose two 
    502  * commands "help" and "hold" are currently the only commands registered in 
    503  * the CLI application. In this case, specifying "he" and "hel" would also 
    504  * match "help" command, and similarly "ho" and "hol" would also match "hold" 
    505  * command, but specifying "h" only would yield an error as it would match 
    506  * more than one commands. This matching behavior can be turned off by 
    507  * setting \a pj_cli_cfg.exact_cmd to PJ_TRUE. 
    508  * 
    509451 * Zero or more arguments follow the command name. Arguments are separated by 
    510452 * one or more whitespaces. Argument may be placed inside a pair of quotes, 
     
    517459 * 
    518460 * The cmdline may be followed by an extra newline (LF or CR-LF characters), 
    519  * which simply will be ignored. However any more characters following this 
    520  * newline will cause an error to be returned. 
     461 * which will be removed by the function. However any more characters 
     462 * following this newline will cause an error to be returned. 
    521463 * 
    522464 * @param sess          The CLI session. 
Note: See TracChangeset for help on using the changeset viewer.