/* 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 u_cl.h 
 *  $RCSfile: $
 *  $Revision: #1 $
 *  $Date: 2015/05/29 $
 *  $Author: brianpc.huang $
 *  
 *  @par Description:
 *         This file exports all compression library specific definitions and structures.
 */
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/*! @defgroup groupMW_CL  Compress Lib
 *
 *  @ingroup groupMW
 *  @brief Provides constant,type definitions and function of the Compress Lib. Compress Lib is a middleware component that is responsible for Compress and Uncompress.
 *
 *  %MW Application API would be used by TV Application, lot of these APIs would
 *   be wrapped from Exported API
 *
 *  @see groupMW
 *  @{ 
 */
/*----------------------------------------------------------------------------*/

#ifndef _U_CL_H_
#define _U_CL_H_

/*-----------------------------------------------------------------------------
                    include files
 ----------------------------------------------------------------------------*/

/*-----------------------------------------------------------------------------
                    macros, defines, typedefs, enums
 ----------------------------------------------------------------------------*/
/*------------------------------------------------------------------*/
/*! @enum CL_NFY_EVENT_TYPE_T
 *  @brief Notification type for "open" callback function,such as "open engine",
              "open archive" and "open entry". 
 *  @code
 *  typedef enum
 *  {
 *      CL_NFY_HANDLE_CLOSED_TYPE
 *  } CL_NFY_EVENT_TYPE_T;
 *  @endcode
 *  @li@c  CL_NFY_HANDLE_CLOSED_TYPE                         - Call back type: handle closed.
 */
/*------------------------------------------------------------------*/
typedef enum
{
    CL_NFY_HANDLE_CLOSED_TYPE
} CL_NFY_EVENT_TYPE_T;
/*------------------------------------------------------------------*/
/*! @enum CL_QUERY_INFO_TYPE_T
 *  @brief Type for query information of a archive. 
 *  @code
 *  typedef enum
 *  {
 *      CL_QUERY_GLOBAL_COMMENT_TYPE,
 *      CL_QUERY_ENTRY_INFO_TYPE,
 *      CL_QUERY_ENTRY_NAME_TYPE,
 *      CL_QUERY_ENTRY_COMMENT_TYPE
 *  }   CL_QUERY_INFO_TYPE_T;
 *  @endcode
 *  @li@c  CL_QUERY_GLOBAL_COMMENT_TYPE                      - Query global commet information.
 *  @li@c  CL_QUERY_ENTRY_INFO_TYPE                          - Query entry information.
 *  @li@c  CL_QUERY_ENTRY_NAME_TYPE                          - Query entry name.
 *  @li@c  CL_QUERY_ENTRY_COMMENT_TYPE                       - Query entry comment information.
 */
/*------------------------------------------------------------------*/
typedef enum
{
    CL_QUERY_GLOBAL_COMMENT_TYPE,
    CL_QUERY_ENTRY_INFO_TYPE,
    CL_QUERY_ENTRY_NAME_TYPE,
    CL_QUERY_ENTRY_COMMENT_TYPE
}   CL_QUERY_INFO_TYPE_T;

/*------------------------------------------------------------------*/
/*! @struct CL_DATE_TIME_T
 *  @brief  Date/time Infomation.
 *  @code
 *  typedef struct _CL_DATE_TIME_T{
 *      UINT16 ui2_sec;            
 *      UINT16 ui2_min;            
 *      UINT16 ui2_hour;           
 *      UINT16 ui2_mday;           
 *      UINT16 ui2_mon;            
 *      UINT16 ui2_year;           
 *  } CL_DATE_TIME_T;
 *  @endcode
 *  @li@c  ui2_sec                                           - Seconds after the minute - [0,59].
 *  @li@c  ui2_min                                           - Minutes after the hour - [0,59].
 *  @li@c  ui2_hour                                          - Hours since midnight - [0,23].
 *  @li@c  ui2_mday                                          - Day of the month - [1,31].
 *  @li@c  ui2_mon                                           - Months since January - [0,11].
 *  @li@c  ui2_year                                          - Years - [1980..2044].
 */
/*------------------------------------------------------------------*/
typedef struct _CL_DATE_TIME_T{
    UINT16 ui2_sec;            /* seconds after the minute - [0,59] */
    UINT16 ui2_min;            /* minutes after the hour - [0,59] */
    UINT16 ui2_hour;           /* hours since midnight - [0,23] */
    UINT16 ui2_mday;           /* day of the month - [1,31] */
    UINT16 ui2_mon;            /* months since January - [0,11] */
    UINT16 ui2_year;           /* years - [1980..2044] */
} CL_DATE_TIME_T;

/*------------------------------------------------------------------*/
/*! @struct CL_ENTRY_INFO_T
 *  @brief Entry information.
 *  @code
 *  typedef struct _CL_ENTRY_INFO_T
 *  {
 *      CL_DATE_TIME_T  t_date_time;
 *      UINT32          ui4_compressed_size;      
 *      UINT32          ui4_decompressed_size;    
 *      UINT16          ui2_compression_method;   
 *  } CL_ENTRY_INFO_T;
 *  @endcode
 *  @li@c  t_date_time                                       - Compressed Data\Time.
 *  @li@c  ui4_compressed_size                               - Compressed size                 4 bytes. 
 *  @li@c  ui4_decompressed_size                             - Uncompressed size               4 bytes.
 *  @li@c  ui2_compression_method                            -Compression method              2 bytes. 
 */
/*------------------------------------------------------------------*/
typedef struct _CL_ENTRY_INFO_T
{
    CL_DATE_TIME_T  t_date_time;
    UINT32          ui4_compressed_size;      /* compressed size  4 bytes */
    UINT32          ui4_decompressed_size;    /* uncompressed size  4 bytes */
    UINT16          ui2_compression_method;   /* compression method  2 bytes */ 
} CL_ENTRY_INFO_T;

#define CL_NULL_PARAM_TYPE    0x0    /**< Null param.       */

#define CL_READ_MODE ((UINT8) 0x01)    /**< Read mode.       */
#define CL_WRITE_MODE ((UINT8) 0x02)    /**< Write mode.       */
#define CL_CREATE_MODE ((UINT8) 0x04)    /**< Create mode.       */
#define CL_APPEND_MODE ((UINT8) 0x08)    /**< Append mode.       */
/************************************************************************/
/* Error code                                                           */
/************************************************************************/
#define CLR_OK                        ((INT32)    0)    /**< Ok.       */
#define CLR_INSUFFICIENT_BUFFER       ((INT32)   -1)    /**< Insuffucuent buffer.       */
#define CLR_COMPRESS_ERROR            ((INT32)   -2)    /**< Compress error.       */
#define CLR_DECOMPRESS_ERROR          ((INT32)   -3)    /**< Decompress error.       */
#define CLR_FILE_OR_DIR_MISSING       ((INT32)   -4)    /**< File or directory missing.       */
#define CLR_INV_ARG                   ((INT32)   -5)    /**< Argument invalid.       */
#define CLR_BAD_ARCHIVE               ((INT32)   -6)    /**< Bad archive.       */
#define CLR_INV_HANDLE                ((INT32)   -7)    /**< Handle invalid.       */
#define CLR_OUT_OF_HANDLE             ((INT32)   -8)    /**< Out of handle.       */
#define CLR_ENG_NOT_FOUND             ((INT32)   -9)    /**< Not support this compress type.       */
#define CLR_OUT_OF_MEMORY             ((INT32)   -10)    /**< Out of memory.       */
#define CLR_FCT_NOT_SUPPORT           ((INT32)   -11)    /**< Function not support.       */
#define CLR_NAME_EXIST                ((INT32)   -12)    /**< File name is already exist.       */
#define CLR_CLI_ERROR                 ((INT32)   -13)    /**< Cli cmd error.       */
#define CLR_AUTOFREE_ERROR            ((INT32)   -14)    /**< Free resource error.       */

/*-----------------------------------------------------------------------------
                    functions declarations
 ----------------------------------------------------------------------------*/

#endif /* _U_CL_H_ */


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