File Coverage

ulib/parse.c
Criterion Covered Total %
statement 21 23 91.3
branch 19 22 86.3
condition n/a
subroutine n/a
pod n/a
total 40 45 88.8


line stmt bran cond sub pod time code
1             #ifdef __cplusplus
2             extern "C" {
3             #endif
4              
5             #include "ulib/parse.h"
6              
7             #ifdef __cplusplus
8             }
9             #endif
10              
11 348           IV uu_parse(const char *in, struct_uu_t *out) {
12             int i;
13             const char *cp;
14             char buf[3];
15              
16 348 100         if (strlen(in) != 36)
17 6           return -1;
18 12996 100         for (i=0, cp = in; i <= 36; i++,cp++) {
19 12654 100         if ((i == 8) || (i == 13) || (i == 18) || (i == 23)) {
    100          
    100          
    100          
20 1368 50         if (*cp == '-')
21 1368           continue;
22 0           return -1;
23             }
24 11286 100         if (i == 36 && *cp == 0)
    50          
25 342           continue;
26 10944 50         if (!isxdigit(*cp))
27 0           return -1;
28             }
29 342           out->v1.time_low = strtoul(in, NULL, 16);
30 342           out->v1.time_mid = (U16)strtoul(in+9, NULL, 16);
31 342           out->v1.time_high_and_version = (U16)strtoul(in+14, NULL, 16);
32 342           out->v1.clock_seq_and_variant = (U16)strtoul(in+19, NULL, 16);
33 342           cp = in+24;
34 342           buf[2] = 0;
35 2394 100         for (i=0; i < 6; i++) {
36 2052           buf[0] = *cp++;
37 2052           buf[1] = *cp++;
38 2052           out->v1.node[i] = (U8)strtoul(buf, NULL, 16);
39             }
40              
41 342           return 0;
42             }
43              
44             /* ex:set ts=2 sw=2 itab=spaces: */