Commit c47b1ca3 authored by Julien Cristau's avatar Julien Cristau Committed by Bernhard Link

Add a DIVIDE_COUNT directive

Complements DECREMENT_COUNT to manipulate counter values
parent 7f32df39
2011-02-06
* add a 'DIVIDE_COUNT' directive
2011-01-29
* add a 'SIZE' directive to limit some structure to an explicit size
(in VarStructs everything after that size is printed as unexpected
......
......@@ -1256,6 +1256,12 @@ static size_t print_parameters(struct connection *c, const unsigned char *buffer
stored -= p->offse;
printspace = false;
continue;
case ft_DIVIDE_STORED:
if (stored % p->offse)
fprintf(stderr, "count (%lu) not divisible by %zu\n", stored, p->offse);
stored /= p->offse;
printspace = false;
continue;
case ft_SET:
stored = p->offse;
printspace = false;
......@@ -1392,6 +1398,7 @@ static size_t print_parameters(struct connection *c, const unsigned char *buffer
case ft_SET_SIZE:
case ft_GET:
case ft_DECREMENT_STORED:
case ft_DIVIDE_STORED:
case ft_SET:
case ft_EVENT:
case ft_FRACTION16_16:
......
......@@ -127,8 +127,10 @@ struct parameter {
/* a 64 bit number consisting of first the high 32 bit, then
* the low 32 bti */
ft_INT32_32,
/* set stored value to specific value */
/* decrement stored value by specific value */
ft_DECREMENT_STORED,
ft_DIVIDE_STORED,
/* set stored value to specific value */
ft_SET
} type;
union parameter_option {
......
......@@ -1115,6 +1115,20 @@ static bool parse_parameters(struct parser *parser, struct variable *variable, b
ft_DECREMENT_STORED, number, NULL);
continue;
}
if( strcmp(position, "DIVIDE_COUNT") == 0) {
const char *v;
if( !state->store_set ) {
error(parser, "store variable must be set before it can be changed!");
}
v = get_const_token(parser, false);
number = parse_number(parser, v);
no_more_arguments(parser);
new_parameter_special(parser, &last,
ft_DIVIDE_STORED, number, NULL);
continue;
}
if( strcmp(position, "RESET_COUNTER") == 0 ) {
no_more_arguments(parser);
state->store_set = false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment