MCPcopy Create free account
hub / github.com/apache/httpd / md_timeslice_parse

Function md_timeslice_parse

modules/md/md_time.c:247–275  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

245}
246
247const char *md_timeslice_parse(md_timeslice_t **pts, apr_pool_t *p,
248 const char *val, apr_interval_time_t norm)
249{
250 md_timeslice_t *ts;
251 int percent = 0;
252
253 *pts = NULL;
254 if (!val) {
255 return "cannot parse NULL value";
256 }
257
258 ts = apr_pcalloc(p, sizeof(*ts));
259 if (md_duration_parse(&ts->len, val, "d") == APR_SUCCESS) {
260 *pts = ts;
261 return NULL;
262 }
263 else {
264 switch (percentage_parse(val, &percent)) {
265 case APR_SUCCESS:
266 ts->norm = norm;
267 ts->len = apr_time_from_sec((apr_time_sec(norm) * percent / 100L));
268 *pts = ts;
269 return NULL;
270 case APR_BADARG:
271 return "percent must be less than 100";
272 }
273 }
274 return "has unrecognized format";
275}
276
277const char *md_timeslice_format(const md_timeslice_t *ts, apr_pool_t *p) {
278 if (ts->norm > 0) {

Callers 5

md_from_jsonFunction · 0.85

Calls 2

md_duration_parseFunction · 0.85
percentage_parseFunction · 0.85

Tested by

no test coverage detected