MCPcopy Index your code
hub / github.com/F-Stack/f-stack / parse_lt

Function parse_lt

tools/libutil/login_times.c:61–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59
60
61login_time_t
62parse_lt(const char *str)
63{
64 login_time_t t;
65
66 memset(&t, 0, sizeof t);
67 t.lt_dow = LTM_NONE;
68 if (str && *str && strcmp(str, "Never") != 0 && strcmp(str, "None") != 0) {
69 int i;
70 login_time_t m = t;
71 char *p;
72 char buf[64];
73
74 /* Make local copy and force lowercase to simplify parsing */
75 strlcpy(buf, str, sizeof buf);
76 for (i = 0; buf[i]; i++)
77 buf[i] = (char)tolower(buf[i]);
78 p = buf;
79
80 while (isalpha(*p)) {
81
82 i = 0;
83 while (dws[i].dw && strncmp(p, dws[i].dw, dws[i].cn) != 0)
84 i++;
85 if (dws[i].dw == NULL)
86 break;
87 m.lt_dow |= dws[i].fl;
88 p += dws[i].cn;
89 }
90
91 if (m.lt_dow == LTM_NONE) /* No (valid) prefix, assume any */
92 m.lt_dow |= LTM_ANY;
93
94 if (isdigit(*p))
95 p = parse_time(p, &m.lt_start);
96 else
97 m.lt_start = 0;
98 if (*p == '-')
99 p = parse_time(p + 1, &m.lt_end);
100 else
101 m.lt_end = 1440;
102
103 t = m;
104 }
105 return (t);
106}
107
108
109int

Callers 1

login_timelistFunction · 0.85

Calls 8

memsetFunction · 0.85
strcmpFunction · 0.85
tolowerFunction · 0.85
isalphaFunction · 0.85
strncmpFunction · 0.85
isdigitFunction · 0.85
parse_timeFunction · 0.85
strlcpyFunction · 0.50

Tested by

no test coverage detected