7e7cdca78e6a67757188406c8de9db42fcd17881Timo Sirainen#ifndef PENALTY_H
7e7cdca78e6a67757188406c8de9db42fcd17881Timo Sirainen#define PENALTY_H
7e7cdca78e6a67757188406c8de9db42fcd17881Timo Sirainen
5566faf0b48f0b77b0134f34130bdc7842c844ebTimo Sirainen#define PENALTY_MAX_VALUE ((1 << 16)-1)
5566faf0b48f0b77b0134f34130bdc7842c844ebTimo Sirainen
7e7cdca78e6a67757188406c8de9db42fcd17881Timo Sirainenstruct penalty *penalty_init(void);
7e7cdca78e6a67757188406c8de9db42fcd17881Timo Sirainenvoid penalty_deinit(struct penalty **penalty);
7e7cdca78e6a67757188406c8de9db42fcd17881Timo Sirainen
7e7cdca78e6a67757188406c8de9db42fcd17881Timo Sirainenvoid penalty_set_expire_secs(struct penalty *penalty, unsigned int expire_secs);
7e7cdca78e6a67757188406c8de9db42fcd17881Timo Sirainen
7e7cdca78e6a67757188406c8de9db42fcd17881Timo Sirainenunsigned int penalty_get(struct penalty *penalty, const char *ident,
5566faf0b48f0b77b0134f34130bdc7842c844ebTimo Sirainen time_t *last_penalty_r);
5566faf0b48f0b77b0134f34130bdc7842c844ebTimo Sirainen/* if checksum is non-zero and it already exists for ident, the value
5566faf0b48f0b77b0134f34130bdc7842c844ebTimo Sirainen is set to "value-1", otherwise it's set to "value". */
5566faf0b48f0b77b0134f34130bdc7842c844ebTimo Sirainenvoid penalty_inc(struct penalty *penalty, const char *ident,
5566faf0b48f0b77b0134f34130bdc7842c844ebTimo Sirainen unsigned int checksum, unsigned int value);
5566faf0b48f0b77b0134f34130bdc7842c844ebTimo Sirainen
5566faf0b48f0b77b0134f34130bdc7842c844ebTimo Sirainenbool penalty_has_checksum(struct penalty *penalty, const char *ident,
5566faf0b48f0b77b0134f34130bdc7842c844ebTimo Sirainen unsigned int checksum);
8825740187b8aaca9c39c4fd6a0b79d480eb143fTimo Sirainenvoid penalty_dump(struct penalty *penalty, struct ostream *output);
7e7cdca78e6a67757188406c8de9db42fcd17881Timo Sirainen
7e7cdca78e6a67757188406c8de9db42fcd17881Timo Sirainen#endif