LCOV - code coverage report
Current view: top level - util - sss_tc_utf8.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 13 13 100.0 %
Date: 2012-11-29 Functions: 2 2 100.0 %
Branches: 4 8 50.0 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :     Authors:
       3                 :            :         Jakub Hrozek <jhrozek@redhat.com>
       4                 :            : 
       5                 :            :     Copyright (C) 2011 Red Hat
       6                 :            : 
       7                 :            :     This program is free software; you can redistribute it and/or modify
       8                 :            :     it under the terms of the GNU General Public License as published by
       9                 :            :     the Free Software Foundation; either version 3 of the License, or
      10                 :            :     (at your option) any later version.
      11                 :            : 
      12                 :            :     This program is distributed in the hope that it will be useful,
      13                 :            :     but WITHOUT ANY WARRANTY; without even the implied warranty of
      14                 :            :     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      15                 :            :     GNU General Public License for more details.
      16                 :            : 
      17                 :            :     You should have received a copy of the GNU General Public License
      18                 :            :     along with this program.  If not, see <http://www.gnu.org/licenses/>.
      19                 :            : */
      20                 :            : 
      21                 :            : #include <talloc.h>
      22                 :            : #include "util/sss_utf8.h"
      23                 :            : 
      24                 :            : char *
      25                 :          2 : sss_tc_utf8_str_tolower(TALLOC_CTX *mem_ctx, const char *s)
      26                 :            : {
      27                 :            :     size_t nlen;
      28                 :            :     uint8_t *ret;
      29                 :            : 
      30                 :          2 :     ret = sss_tc_utf8_tolower(mem_ctx, (const uint8_t *) s, strlen(s), &nlen);
      31         [ +  - ]:          2 :     if (!ret) return NULL;
      32                 :            : 
      33                 :          2 :     ret = talloc_realloc(mem_ctx, ret, uint8_t, nlen+1);
      34         [ +  - ]:          2 :     if (!ret) return NULL;
      35                 :            : 
      36                 :          2 :     ret[nlen] = '\0';
      37                 :            :     return (char *) ret;
      38                 :            : }
      39                 :            : 
      40                 :            : uint8_t *
      41                 :          3 : sss_tc_utf8_tolower(TALLOC_CTX *mem_ctx, const uint8_t *s, size_t len, size_t *_nlen)
      42                 :            : {
      43                 :            :     uint8_t *lower;
      44                 :            :     uint8_t *ret;
      45                 :            :     size_t nlen;
      46                 :            : 
      47                 :          3 :     lower = sss_utf8_tolower(s, len, &nlen);
      48         [ +  - ]:          3 :     if (!lower) return NULL;
      49                 :            : 
      50                 :          3 :     ret = talloc_memdup(mem_ctx, lower, nlen);
      51                 :          3 :     sss_utf8_free(lower);
      52         [ +  - ]:          3 :     if (!ret) return NULL;
      53                 :            : 
      54                 :          3 :     *_nlen = nlen;
      55                 :            :     return ret;
      56                 :            : }
      57                 :            : 

Generated by: LCOV version 1.9