LCOV - code coverage report
Current view: top level - sss_client/libwbclient - wbc_guid.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 36 0.0 %
Date: 2016-06-29 Functions: 0 2 0.0 %

          Line data    Source code
       1             : /*
       2             :    Unix SMB/CIFS implementation.
       3             : 
       4             :    Winbind client API
       5             : 
       6             :    Copyright (C) Gerald (Jerry) Carter 2007
       7             : 
       8             : 
       9             :    This library is free software; you can redistribute it and/or
      10             :    modify it under the terms of the GNU Lesser General Public
      11             :    License as published by the Free Software Foundation; either
      12             :    version 3 of the License, or (at your option) any later version.
      13             : 
      14             :    This library is distributed in the hope that it will be useful,
      15             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      16             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      17             :    Library General Public License for more details.
      18             : 
      19             :    You should have received a copy of the GNU Lesser General Public License
      20             :    along with this program.  If not, see <http://www.gnu.org/licenses/>.
      21             : */
      22             : 
      23             : /* Required Headers */
      24             : 
      25             : #include "libwbclient.h"
      26             : 
      27             : /* Convert a binary GUID to a character string */
      28           0 : wbcErr wbcGuidToString(const struct wbcGuid *guid,
      29             :                char **guid_string)
      30             : {
      31             :     char *result;
      32             : 
      33           0 :     result = (char *)wbcAllocateMemory(37, 1, NULL);
      34           0 :     if (result == NULL) {
      35           0 :         return WBC_ERR_NO_MEMORY;
      36             :     }
      37           0 :     snprintf(result, 37,
      38             :          "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
      39           0 :          guid->time_low, guid->time_mid,
      40           0 :          guid->time_hi_and_version,
      41           0 :          guid->clock_seq[0],
      42           0 :          guid->clock_seq[1],
      43           0 :          guid->node[0], guid->node[1],
      44           0 :          guid->node[2], guid->node[3],
      45           0 :          guid->node[4], guid->node[5]);
      46           0 :     *guid_string = result;
      47             : 
      48           0 :     return WBC_ERR_SUCCESS;
      49             : }
      50             : 
      51             : /* @brief Convert a character string to a binary GUID */
      52           0 : wbcErr wbcStringToGuid(const char *str,
      53             :                struct wbcGuid *guid)
      54             : {
      55             :     uint32_t time_low;
      56             :     uint32_t time_mid, time_hi_and_version;
      57             :     uint32_t clock_seq[2];
      58             :     uint32_t node[6];
      59             :     int i;
      60           0 :     wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
      61             : 
      62           0 :     if (!guid) {
      63           0 :         wbc_status = WBC_ERR_INVALID_PARAM;
      64           0 :         BAIL_ON_WBC_ERROR(wbc_status);
      65             :     }
      66             : 
      67           0 :     if (!str) {
      68           0 :         wbc_status = WBC_ERR_INVALID_PARAM;
      69           0 :         BAIL_ON_WBC_ERROR(wbc_status);
      70             :     }
      71             : 
      72           0 :     if (11 == sscanf(str, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
      73             :              &time_low, &time_mid, &time_hi_and_version,
      74             :              &clock_seq[0], &clock_seq[1],
      75             :              &node[0], &node[1], &node[2], &node[3], &node[4], &node[5])) {
      76           0 :             wbc_status = WBC_ERR_SUCCESS;
      77           0 :     } else if (11 == sscanf(str, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
      78             :                 &time_low, &time_mid, &time_hi_and_version,
      79             :                 &clock_seq[0], &clock_seq[1],
      80             :                 &node[0], &node[1], &node[2], &node[3], &node[4], &node[5])) {
      81           0 :             wbc_status = WBC_ERR_SUCCESS;
      82             :     }
      83             : 
      84           0 :     BAIL_ON_WBC_ERROR(wbc_status);
      85             : 
      86           0 :     guid->time_low = time_low;
      87           0 :     guid->time_mid = time_mid;
      88           0 :     guid->time_hi_and_version = time_hi_and_version;
      89           0 :     guid->clock_seq[0] = clock_seq[0];
      90           0 :     guid->clock_seq[1] = clock_seq[1];
      91             : 
      92           0 :     for (i=0;i<6;i++) {
      93           0 :         guid->node[i] = node[i];
      94             :     }
      95             : 
      96           0 :     wbc_status = WBC_ERR_SUCCESS;
      97             : 
      98             : done:
      99           0 :     return wbc_status;
     100             : }

Generated by: LCOV version 1.10