usage();
}
- q = str2bytes(l_arg, &l_size);
+ q = str2bytes(l_arg, &l_size, 0);
if (q != NULL) {
fprintf(stderr, "Parameter error:\n");
fprintf(stderr, "\t-l ...: %s\n", q);
uint32_t crc32_l(const void *p1, unsigned l);
/* from libvarnish/num.c */
-const char *str2bytes(const char *p, uintmax_t *r);
+const char *str2bytes(const char *p, uintmax_t *r, uintmax_t rel);
/* from libvarnish/time.c */
void TIM_format(double t, char *p);
#include <libvarnish.h>
const char *
-str2bytes(const char *p, uintmax_t *r)
+str2bytes(const char *p, uintmax_t *r, uintmax_t rel)
{
int i;
double l;
case 't': l *= ((uintmax_t)1 << 40); break;
case 'p': l *= ((uintmax_t)1 << 50); break;
case 'e': l *= ((uintmax_t)1 << 60); break;
+ case '%':
+ /* Percentage of 'rel' arg */
+ if (rel != 0) {
+ l *= 1e-2 * rel;
+ break;
+ }
+ /*FALLTHROUGH*/
default:
return ("Unknown scaling suffix [bkmgtpe] allowed");
}