LCOV - code coverage report
Current view: top level - home/magsoft/trunks/SVT-AV1/Source/Lib/Encoder/Codec - EbString.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 4 0.0 %
Date: 2019-11-25 17:12:20 Functions: 0 1 0.0 %

          Line data    Source code
       1             : /*------------------------------------------------------------------
       2             : * strncpy_s.c / strcpy_s.c / strnlen_s.c
       3             : *
       4             : * October 2008, Bo Berry
       5             : *
       6             : * Copyright � 2008-2011 by Cisco Systems, Inc
       7             : * All rights reserved.
       8             : 
       9             : * safe_str_constraint.c
      10             : *
      11             : * October 2008, Bo Berry
      12             : * 2012, Jonathan Toppins <jtoppins@users.sourceforge.net>
      13             : *
      14             : * Copyright � 2008, 2009, 2012 Cisco Systems
      15             : * All rights reserved.
      16             : 
      17             : * ignore_handler_s.c
      18             : *
      19             : * 2012, Jonathan Toppins <jtoppins@users.sourceforge.net>
      20             : *
      21             : * Copyright � 2012 Cisco Systems
      22             : * All rights reserved.
      23             : *
      24             : * Permission is hereby granted, free of charge, to any person
      25             : * obtaining a copy of this software and associated documentation
      26             : * files (the "Software"), to deal in the Software without
      27             : * restriction, including without limitation the rights to use,
      28             : * copy, modify, merge, publish, distribute, sublicense, and/or
      29             : * sell copies of the Software, and to permit persons to whom the
      30             : * Software is furnished to do so, subject to the following
      31             : * conditions:
      32             : *
      33             : * The above copyright notice and this permission notice shall be
      34             : * included in all copies or substantial portions of the Software.
      35             : *
      36             : * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
      37             : * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
      38             : * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
      39             : * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
      40             : * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
      41             : * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      42             : * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
      43             : * OTHER DEALINGS IN THE SOFTWARE.
      44             : *------------------------------------------------------------------
      45             : */
      46             : #ifndef EbString_h
      47             : #define EbString_h
      48             : 
      49             : #include <stddef.h>
      50             : #include <stdint.h>
      51             : 
      52             : #ifdef __cplusplus
      53             : extern "C" {
      54             : #endif // __cplusplus
      55             : 
      56             : #ifndef _RSIZE_T_DEFINED
      57             : typedef size_t rsize_t;
      58             : #define _RSIZE_T_DEFINED
      59             : #endif  /* _RSIZE_T_DEFINED */
      60             : 
      61             : #ifndef _ERRNO_T_DEFINED
      62             : #define _ERRNO_T_DEFINED
      63             : typedef int32_t errno_t;
      64             : #endif  /* _ERRNO_T_DEFINED */
      65             : 
      66             : #ifndef EOK
      67             : #define EOK             ( 0 )
      68             : #endif
      69             : 
      70             : #ifndef ESZEROL
      71             : #define ESZEROL         ( 401 )       /* length is zero              */
      72             : #endif
      73             : 
      74             : #ifndef ESLEMIN
      75             : #define ESLEMIN         ( 402 )       /* length is below min         */
      76             : #endif
      77             : 
      78             : #ifndef ESLEMAX
      79             : #define ESLEMAX         ( 403 )       /* length exceeds max          */
      80             : #endif
      81             : 
      82             : #ifndef ESNULLP
      83             : #define ESNULLP         ( 400 )       /* null ptr                    */
      84             : #endif
      85             : 
      86             : #ifndef ESOVRLP
      87             : #define ESOVRLP         ( 404 )       /* overlap undefined           */
      88             : #endif
      89             : 
      90             : #ifndef ESEMPTY
      91             : #define ESEMPTY         ( 405 )       /* empty string                */
      92             : #endif
      93             : 
      94             : #ifndef ESNOSPC
      95             : #define ESNOSPC         ( 406 )       /* not enough space for s2     */
      96             : #endif
      97             : 
      98             : #ifndef ESUNTERM
      99             : #define ESUNTERM        ( 407 )       /* unterminated string         */
     100             : #endif
     101             : 
     102             : #ifndef ESNODIFF
     103             : #define ESNODIFF        ( 408 )       /* no difference               */
     104             : #endif
     105             : 
     106             : #ifndef ESNOTFND
     107             : #define ESNOTFND        ( 409 )       /* not found                   */
     108             : #endif
     109             : 
     110             : #define RSIZE_MAX_STR      ( 4UL << 10 )      /* 4KB */
     111             : #define RCNEGATE(x)  (x)
     112             : 
     113             : #ifndef sldebug_printf
     114             : #define sldebug_printf(...)
     115             : #endif
     116             : 
     117             : typedef void(*constraint_handler_t) (const char * /* msg */,
     118             :     void *       /* ptr */,
     119             :     errno_t      /* error */);
     120             : 
     121             : /*
     122             : * Function used by the libraries to invoke the registered
     123             : * runtime-constraint handler. Always needed.
     124             : */
     125             : extern void eb_invoke_safe_str_constraint_handler(
     126             :     const char *msg,
     127             :     void *ptr,
     128             :     errno_t error);
     129             : 
     130           0 : static inline void eb_handle_error(char *orig_dest, rsize_t orig_dmax,
     131             :     char *err_msg, errno_t err_code)
     132             : {
     133             :     (void)orig_dmax;
     134           0 :     *orig_dest = '\0';
     135             : 
     136           0 :     eb_invoke_safe_str_constraint_handler(err_msg, NULL, err_code);
     137           0 :     return;
     138             : }
     139             : 
     140             : #define sl_default_handler eb_ignore_handler_s
     141             : extern void eb_ignore_handler_s(const char *msg, void *ptr, errno_t error);
     142             : 
     143             : /* string copy */
     144             : errno_t eb_strcpy_ss(
     145             :     char *dest, rsize_t dmax, const char *src);
     146             : 
     147             : /* fitted string copy */
     148             : errno_t eb_strncpy_ss(
     149             :     char *dest, rsize_t dmax, const char *src, rsize_t slen);
     150             : 
     151             : /* string length */
     152             : rsize_t eb_strnlen_ss(
     153             :     const char *s, rsize_t smax);
     154             : 
     155             : #define EB_STRNCPY(dst, dst_size, src, count) \
     156             :     eb_strncpy_ss(dst, dst_size, src, count)
     157             : 
     158             : #define EB_STRCPY(dst, size, src) \
     159             :     eb_strcpy_ss(dst, size, src)
     160             : 
     161             : #define EB_STRCMP(target,token) \
     162             :     strcmp(target,token)
     163             : 
     164             : #define EB_STRLEN(target, max_size) \
     165             :     eb_strnlen_ss(target, max_size)
     166             : 
     167             : #ifdef __cplusplus
     168             : }
     169             : #endif // __cplusplus
     170             : 
     171             : #endif // EbString_h
     172             : /* File EOF */

Generated by: LCOV version 1.14