| 245 | } |
| 246 | |
| 247 | const 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 | |
| 277 | const char *md_timeslice_format(const md_timeslice_t *ts, apr_pool_t *p) { |
| 278 | if (ts->norm > 0) { |
no test coverage detected