#ifndef _LIMIT_Header
#define _LIMIT_Header

// flimit is not stored on disk so no filling.
// ulimit is.
typedef struct ULIMIT {double daily; double monthly; int ncon;} Ulimit;
typedef struct FLIMIT {int nref; char *userip; Ulimit cur; Ulimit max; double wused; int rday; struct FLIMIT *next; } Flimit;

int limit_report(char *fname, void (*pfn)(void *p1, char *bf, int len), void *p1, Wordlist *wordlist);
int limit_showuser(char *user, double *val);

int limit_hash(char *s);
int limit_init(void);
int limit_rewrite(void);
int limit_init_one(char *fname);
Flimit *limit_find(char *user);
Flimit *limit_login(char *user, Ulimit *u, int localonly, int rday);
int limit_add(Flimit *fl, double bytes, char *reason);
int limit_logout(Flimit *fl, int localonly);
int limit_write_todisk(Flimit *fl);
int limit_exit(void);
int limit_newday(void);
int limit_newmonth(int day);
int limit_mutex_wait(int line);
int limit_mutex_release(void);
Flimit *limit_create(char *user);
int limit_wide_client(char *ip, char *cmd, char *response);
int limit_wide_login(Flimit *fl);
int limit_wide_logout(Flimit *fl);
int limit_wide_setup(char *host, char *pass);
int limit_wide_cmd(char *userip, Ulimit *used, char *cmd, double add, int rday);
int limit_wide_mutex_wait(void);
int limit_reset(char *uname);
double limit_monthly(char *uname);


#endif /*LIMIT_Header*/