File: leaky-bucket.h

package info (click to toggle)
mcelog 104-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 996 kB
  • ctags: 1,508
  • sloc: ansic: 7,739; sh: 481; makefile: 87
file content (31 lines) | stat: -rw-r--r-- 748 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#ifndef LEAKY_BUCKET_H
#define LEAKY_BUCKET_H 1

#include <time.h>

/* Leaky bucket algorithm for triggers */

struct bucket_conf {
	unsigned capacity;
	unsigned agetime;
	unsigned char tunit;	/* 'd','h','m','s' */
	unsigned char log;
	char *trigger;
};

struct leaky_bucket {
	unsigned count;
	unsigned excess;
	time_t   tstamp;
};

int bucket_account(const struct bucket_conf *c, struct leaky_bucket *b, 
		   unsigned inc);
int __bucket_account(const struct bucket_conf *c, struct leaky_bucket *b, 
		   unsigned inc, time_t time);
char *bucket_output(const struct bucket_conf *c, struct leaky_bucket *b);
int bucket_conf_init(struct bucket_conf *c, const char *rate);
void bucket_init(struct leaky_bucket *b);
time_t bucket_time(void);

#endif