LCOV - code coverage report
Current view: top level - lib/util - util_str_hex.c (source / functions) Hit Total Coverage
Test: coverage report for support-claim-type-attributes 6b5c566e Lines: 31 36 86.1 %
Date: 2023-11-21 12:31:41 Functions: 3 3 100.0 %

          Line data    Source code
       1             : #include "replace.h"
       2             : #include "util_str_hex.h"
       3             : #include "lib/util/data_blob.h"
       4             : #include "librpc/gen_ndr/misc.h"
       5             : 
       6   438690300 : static bool hex_uint16(const char *in, uint16_t *out)
       7             : {
       8   438690300 :         uint8_t hi=0, lo=0;
       9   438690300 :         bool ok = hex_byte(in, &hi) && hex_byte(in+2, &lo);
      10   438690300 :         *out = (((uint16_t)hi)<<8) + lo;
      11   438690300 :         return ok;
      12             : }
      13             : 
      14   109885684 : bool hex_uint32(const char *in, uint32_t *out)
      15             : {
      16   109885684 :         uint16_t hi=0, lo=0;
      17   109885684 :         bool ok = hex_uint16(in, &hi) && hex_uint16(in+4, &lo);
      18   109885684 :         *out = (((uint32_t)hi)<<16) + lo;
      19   109885684 :         return ok;
      20             : }
      21             : 
      22   109459483 : bool parse_guid_string(const char *s, struct GUID *guid)
      23             : {
      24     2502397 :         bool ok;
      25     2502397 :         int i;
      26             :         /* "e12b56b6-0a95-11d1-adbb-00c04fd8d5cd"
      27             :                 |     |    |    |    |
      28             :                 |     |    |    |    \ node[6]
      29             :                 |     |    |    \_____ clock_seq[2]
      30             :                 |     |    \__________ time_hi_and_version
      31             :                 |     \_______________ time_mid
      32             :                 \_____________________ time_low
      33             :         */
      34             : 
      35   109459483 :         ok = hex_uint32(s, &guid->time_low);
      36   109459483 :         if (!ok || (s[8] != '-')) {
      37           0 :                 return false;
      38             :         }
      39   109459473 :         s += 9;
      40             : 
      41   109459473 :         ok = hex_uint16(s, &guid->time_mid);
      42   109459473 :         if (!ok || (s[4] != '-')) {
      43           0 :                 return false;
      44             :         }
      45   109459467 :         s += 5;
      46             : 
      47   109459467 :         ok = hex_uint16(s, &guid->time_hi_and_version);
      48   109459467 :         if (!ok || (s[4] != '-')) {
      49           0 :                 return false;
      50             :         }
      51   109459467 :         s += 5;
      52             : 
      53   218918930 :         ok = hex_byte(s, &guid->clock_seq[0]) &&
      54   109459463 :                 hex_byte(s+2, &guid->clock_seq[1]);
      55   109459467 :         if (!ok || (s[4] != '-')) {
      56           0 :                 return false;
      57             :         }
      58   109459461 :         s += 5;
      59             : 
      60   766216189 :         for (i = 0; i < 6; i++) {
      61   656756736 :                 ok = hex_byte(s, &guid->node[i]);
      62   656756736 :                 if (!ok) {
      63           0 :                         return false;
      64             :                 }
      65   656756728 :                 s += 2;
      66             :         }
      67             : 
      68   106957086 :         return true;
      69             : }

Generated by: LCOV version 1.14