LCOV - code coverage report
Current view: top level - providers/ipa - ipa_utils.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 15 15 100.0 %
Date: 2012-11-29 Functions: 1 1 100.0 %
Branches: 8 10 80.0 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :     SSSD
       3                 :            : 
       4                 :            :     IPA Provider Utility Functions
       5                 :            : 
       6                 :            :     Authors:
       7                 :            :         Simo Sorce <ssorce@redhat.com>, Sumit Bose <sbose@redhat.com>
       8                 :            : 
       9                 :            :     Copyright (C) 2009-2010 Red Hat
      10                 :            : 
      11                 :            :     This program is free software; you can redistribute it and/or modify
      12                 :            :     it under the terms of the GNU General Public License as published by
      13                 :            :     the Free Software Foundation; either version 3 of the License, or
      14                 :            :     (at your option) any later version.
      15                 :            : 
      16                 :            :     This program is distributed in the hope that it will be useful,
      17                 :            :     but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :     GNU General Public License for more details.
      20                 :            : 
      21                 :            :     You should have received a copy of the GNU General Public License
      22                 :            :     along with this program.  If not, see <http://www.gnu.org/licenses/>.
      23                 :            : */
      24                 :            : 
      25                 :            : 
      26                 :            : #include <ctype.h>
      27                 :            : 
      28                 :            : #include "providers/ipa/ipa_common.h"
      29                 :            : 
      30                 :          5 : int domain_to_basedn(TALLOC_CTX *memctx, const char *domain, char **basedn)
      31                 :            : {
      32                 :            :     const char *s;
      33                 :            :     char *dn;
      34                 :            :     char *p;
      35                 :            :     int l;
      36                 :            : 
      37         [ +  + ]:          5 :     if (!domain || !basedn) {
      38                 :            :         return EINVAL;
      39                 :            :     }
      40                 :            : 
      41                 :          3 :     s = domain;
      42                 :          3 :     dn = talloc_strdup(memctx, "dc=");
      43                 :            : 
      44         [ +  + ]:          7 :     while ((p = strchr(s, '.'))) {
      45                 :          4 :         l = p - s;
      46                 :          4 :         dn = talloc_asprintf_append_buffer(dn, "%.*s,dc=", l, s);
      47         [ +  - ]:          4 :         if (!dn) {
      48                 :            :             return ENOMEM;
      49                 :            :         }
      50                 :          4 :         s = p + 1;
      51                 :            :     }
      52                 :          3 :     dn = talloc_strdup_append_buffer(dn, s);
      53         [ +  - ]:          3 :     if (!dn) {
      54                 :            :         return ENOMEM;
      55                 :            :     }
      56                 :            : 
      57         [ +  + ]:         37 :     for (p=dn; *p; ++p) {
      58                 :         34 :         *p = tolower(*p);
      59                 :            :     }
      60                 :            : 
      61                 :          3 :     *basedn = dn;
      62                 :          5 :     return EOK;
      63                 :            : }

Generated by: LCOV version 1.9