/* SPDX-License-Identifier: LGPL-2.1-only OR BSD-3-Clause */
/******************************************************************************
 *
 * This file is provided under a dual license.  When you use or
 * distribute this software, you may choose to be licensed under
 * version 2.1 of the GNU Lesser General Public License
 * ("LGPLv2.1 License") or BSD License.
 *
 * LGPLv2.1 License
 *
 * Copyright(C) 2019 MediaTek Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of version 2.1 of the GNU Lesser General Public
 * License as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html for more
 * details.
 *
 * BSD LICENSE
 *
 * Copyright(C) 2019 MediaTek Inc.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 *  * Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *  * Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *  * Neither the name of the copyright holder nor the names of its
 *    contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 *****************************************************************************/

/*----------------------------------------------------------------------------*/
/*! @file c_cli.h  
 * $Revision: #1 $
 * $Date: 2015/11/10 $
 * $Author: dtvbm11 $
 * $CCRevision: /main/DTV_X_HQ_int/1 $
 * $SWAuthor: Alec Lu $
 * $MD5HEX: f5a0c334974816cea20a5ca57a8392f1 $
 *
 * @par Description:
 *         This header file contains CLI related definitions, which are
 *         are exported to applications.  
 *---------------------------------------------------------------------------*/

/*----------------------------------------------------------------------------*/
/*! @addtogroup groupMW_CLI
  *  @brief Provides external function TV Application
  *  %MW Application API would be used by TV Application, lot of these APIs would
  *   be wrapped from Exported API
  *  @see groupMW
  *  @{  
  */
/*----------------------------------------------------------------------------*/

#ifndef _C_CLI_H_
#define _C_CLI_H_

/*-----------------------------------------------------------------------------
                    include files
 ----------------------------------------------------------------------------*/
#include "u_cli.h"

/*-----------------------------------------------------------------------------
                    functions declarations
 ----------------------------------------------------------------------------*/
/*------------------------------------------------------------------*/
/*! @brief  This API attaches a command table to CLI root.
  *  @param [in]   pt_tbl                    References to the command table to be attached.
  *  @param [in]   e_category            References to the category that the command table belongs to.
  *  @param [in]   ui8_group_mask    References to the group(s) that the command table belongs to.
  *  @retval      -CLIR_OK                      Routine successful.
  *  @retval      -CLIR_NOT_INIT            The CLI has not been initialized.
  *  @retval      -CLIR_INV_ARG             One or more invalid arguments.
  *  @retval      -CLIR_CMD_TBL_FULL    Command table is full.
  */
/*------------------------------------------------------------------*/
extern INT32 c_cli_attach_cmd_tbl(CLI_EXEC_T* pt_tbl, 
                                  CLI_CAT_T   e_category,
                                  UINT64      ui8_group_mask);


/*------------------------------------------------------------------*/
/*! @brief  This API adds, deletes, or raplaces an alias element from alias table
  *  @param [in]   ps_alias           Contains the alias to attach.            
  *  @param [in]   ps_cmd           Contains the command string corresponding to the alias. 
  *  @retval      -CLIR_OK                          Routine successful.
  *  @retval      -CLIR_NOT_INIT                The CLI has not been initialized.
  *  @retval      -CLIR_INV_ARG                 One or more invalid arguments.
  *  @retval      -CLIR_ALIAS_TOO_LONG    Alias is too long.
  *  @retval      -CLIR_CMD_TOO_LONG      CLI command is too long.
  *  @retval      -CLIR_ALIAS_TBL_FULL      CLI alias table is full.
  *  @retval      -CLIR_CMD_EXEC_ERROR  CLI command execution failed.  
  */
/*------------------------------------------------------------------*/                                  
extern INT32 c_cli_attach_alias(const CHAR* ps_alias, 
                                const CHAR* ps_cmd);


                                
/*------------------------------------------------------------------*/
/*! @brief  This API parses CLI command and performs corresponding operation.
  *  @param [in]   ps_cmd           Contain the command to parse. 
  *  @retval      -CLIR_OK                          Routine successful.
  *  @retval      -CLIR_NOT_INIT                The CLI has not been initialized.
  *  @retval      -CLIR_INV_ARG                 One or more invalid arguments.
  *  @retval      -CLIR_UNKNOWN_CMD       Unknown CLI command.
  */
/*------------------------------------------------------------------*/
extern INT32 c_cli_parser(const CHAR* ps_cmd);


/*------------------------------------------------------------------*/
/*! @brief  This API parses CLI command and performs corresponding operation. The variable-length argument lists are supported.
  *  @param [in]   ps_cmd          Contain the format.   
  *  @param [in]   ...                  Variable argument list.
  *  @retval      -CLIR_OK                          Routine successful.
  *  @retval      -CLIR_NOT_INIT                The CLI has not been initialized.
  *  @retval      -CLIR_INV_ARG                 One or more invalid arguments.
  *  @retval      -CLIR_UNKNOWN_CMD       Unknown CLI command.
  */
/*------------------------------------------------------------------*/
extern INT32 c_cli_parser_arg(const CHAR* ps_cmd, ...);



/*------------------------------------------------------------------*/
/*! @brief  This API generates a password according to current system date and time.
  *  @param [in]   t_password          Contain the password calculation method.
  *  @retval      -CLIR_OK                          Routine successful.
  *  @retval      -CLIR_CMD_EXEC_ERROR  Input password is incorrect.
  */
/*------------------------------------------------------------------*/
extern INT32 c_cli_passwd(CLI_PASSWD_T t_password);



/*------------------------------------------------------------------*/
/*! @brief  This API waits for the first available character within specific time period.
  *  @param [in]   ui4_time          Contain the waiting time period in ms.
  *  @retval      -ASCII_NULL   The UART queue is empty.
  *  @retval      -Others           The first available character from UART queue.
  */
/*------------------------------------------------------------------*/
extern CHAR c_cli_get_char_timeout(UINT32 ui4_time);



/*------------------------------------------------------------------*/
/*! @brief   This API parses a CLI command for debug level.
  *  @param [in]   i4_argc              Contain the number of arguments.
  *  @param [in]   pps_argv           Contain the points to the argument array.
  *  @param [out] pui2_dbg_level   Contain the value of debug level after parsing.
  *  @retval      -CLIR_OK                          Routine successful.
  *  @retval      -CLIR_CMD_EXEC_ERROR  CLI command execution failed.  
  */
/*------------------------------------------------------------------*/
extern INT32 c_cli_parse_dbg_level(INT32        i4_argc, 
                                   const CHAR** pps_argv,
                                   UINT16*      pui2_dbg_level);
                                   

/*------------------------------------------------------------------*/
/*! @brief   This API display debug level in text format.
  *  @param [in]   ui2_dbg_level     Contain the value of debug level to display.
  *  @retval      -CLIR_OK                          Routine successful.
  */
/*------------------------------------------------------------------*/
extern INT32 c_cli_show_dbg_level(UINT16 ui2_dbg_level);


/*------------------------------------------------------------------*/
/*! @brief   This API parses a CLI command for time measurement level.
  *  @param [in]   i4_argc              Contain the number of arguments.
  *  @param [in]   pps_argv           Contain the points to the argument array.
  *  @param [out] pui2_tms_level   Contain the value of time measurement level after parsing.
  *  @retval      -CLIR_OK                          Routine successful.
  *  @retval      -CLIR_NOT_INIT                The CLI has not been initialized.
  *  @retval      -CLIR_CMD_EXEC_ERROR  Input password is incorrect.
  *  @retval      -CLIR_NOT_ENABLED         CLI is not enabled.
  */
/*------------------------------------------------------------------*/
extern INT32 c_cli_parse_tms_level(INT32        i4_argc, 
                                   const CHAR** pps_argv,
                                   UINT16*      pui2_tms_level);




/*------------------------------------------------------------------*/
/*! @brief   This API display time measurement level in text format.
  *  @param [in]   ui2_tms_level     Contain the value of time measurement level to display.
  *  @retval      -CLIR_OK                          Routine successful.
  *  @retval      -CLIR_NOT_INIT                The CLI has not been initialized.
  *  @retval      -CLIR_NOT_ENABLED         CLI is not enabled.
  */
/*------------------------------------------------------------------*/                                   
extern INT32 c_cli_show_tms_level(UINT16 ui2_tms_level);


/*------------------------------------------------------------------*/
/*! @brief   This API is used to trigger the hotkey callback functions.
  *  @param [in]   pui4_keys     Contains a hotkey array.
  *  @param [in]   ui2_key_len  Contain the length of the hotkey array.
  *  @retval      -CLIR_OK                      Routine successful.
  *  @retval      -CLIR_NOT_INIT            The CLI sub-module has not been initialized.
  *  @retval      -CLIR_INV_ARG             Invalid arguments.
  *  @retval      -CLIR_NOT_ENABLED     CLI sub-module is not enabled.
  */
/*------------------------------------------------------------------*/ 
extern INT32 c_cli_ui_send_hotkeys (UINT32* pui4_keys,
                                    UINT16  ui2_key_len);

#endif /* _C_CLI_H_ */

/*----------------------------------------------------------------------------*/
/*! @} */                                                 /* end of groupMW_CLI */
/*----------------------------------------------------------------------------*/


