annotate src/plugins/quota/quota.h @ 6410:e4eb71ae8e96 HEAD

Changed .h ifdef/defines to use <NAME>_H format.
author Timo Sirainen <tss@iki.fi>
date Sun, 16 Sep 2007 11:31:27 +0300
parents 6edca218d48a
children db66611fd195
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6410
e4eb71ae8e96 Changed .h ifdef/defines to use <NAME>_H format.
Timo Sirainen <tss@iki.fi>
parents: 6032
diff changeset
1 #ifndef QUOTA_H
e4eb71ae8e96 Changed .h ifdef/defines to use <NAME>_H format.
Timo Sirainen <tss@iki.fi>
parents: 6032
diff changeset
2 #define QUOTA_H
3738
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
3
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
4 struct mail;
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
5 struct mailbox;
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
6
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
7 /* Message storage size kilobytes. */
4844
a0ba02928787 Bytes and kilobytes were somewhat mixed up everywhere. Also fixes a
Timo Sirainen <tss@iki.fi>
parents: 4514
diff changeset
8 #define QUOTA_NAME_STORAGE_KILOBYTES "STORAGE"
a0ba02928787 Bytes and kilobytes were somewhat mixed up everywhere. Also fixes a
Timo Sirainen <tss@iki.fi>
parents: 4514
diff changeset
9 /* Message storage size bytes. This is used only internally. */
a0ba02928787 Bytes and kilobytes were somewhat mixed up everywhere. Also fixes a
Timo Sirainen <tss@iki.fi>
parents: 4514
diff changeset
10 #define QUOTA_NAME_STORAGE_BYTES "STORAGE_BYTES"
3738
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
11 /* Number of messages. */
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
12 #define QUOTA_NAME_MESSAGES "MESSAGES"
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
13
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
14 struct quota;
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
15 struct quota_root;
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
16 struct quota_root_iter;
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
17 struct quota_transaction_context;
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
18
4084
51306837698b Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4044
diff changeset
19 struct quota *quota_init(void);
5566
88307a648e0e Use sync_notify() callback to count expunges. This makes the calculation
Timo Sirainen <tss@iki.fi>
parents: 4844
diff changeset
20 void quota_deinit(struct quota **quota);
3738
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
21
4084
51306837698b Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4044
diff changeset
22 /* Create a new quota root. */
4509
e5e79558ac2d Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4330
diff changeset
23 struct quota_root *quota_root_init(struct quota *quota, const char *root_def);
5566
88307a648e0e Use sync_notify() callback to count expunges. This makes the calculation
Timo Sirainen <tss@iki.fi>
parents: 4844
diff changeset
24 void quota_root_deinit(struct quota_root **root);
4084
51306837698b Quota API redesign. Still not perfect, but better than before. Quota backends no longer need to be told where the mails exist. fs backend doesn't work correctly with multiple partitions (if you've multiple namespaces).
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4044
diff changeset
25
4509
e5e79558ac2d Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4330
diff changeset
26 /* Add a new rule too the quota root. Returns 0 if ok, -1 if rule is invalid. */
e5e79558ac2d Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4330
diff changeset
27 int quota_root_add_rule(struct quota_root *root, const char *rule_def,
e5e79558ac2d Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4330
diff changeset
28 const char **error_r);
6032
6edca218d48a Added quota warning commands. Based lightly on a patch by Nicolas Boullis.
Timo Sirainen <tss@iki.fi>
parents: 5566
diff changeset
29 /* Add a new warning rule for the quota root. Returns 0 if ok, -1 if rule is
6edca218d48a Added quota warning commands. Based lightly on a patch by Nicolas Boullis.
Timo Sirainen <tss@iki.fi>
parents: 5566
diff changeset
30 invalid. */
6edca218d48a Added quota warning commands. Based lightly on a patch by Nicolas Boullis.
Timo Sirainen <tss@iki.fi>
parents: 5566
diff changeset
31 int quota_root_add_warning_rule(struct quota_root *root, const char *rule_def,
6edca218d48a Added quota warning commands. Based lightly on a patch by Nicolas Boullis.
Timo Sirainen <tss@iki.fi>
parents: 5566
diff changeset
32 const char **error_r);
4509
e5e79558ac2d Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4330
diff changeset
33
3738
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
34 /* List all quota roots. Returned quota roots are freed by quota_deinit(). */
4509
e5e79558ac2d Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4330
diff changeset
35 struct quota_root_iter *
e5e79558ac2d Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4330
diff changeset
36 quota_root_iter_init(struct quota *quota, struct mailbox *box);
3738
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
37 struct quota_root *quota_root_iter_next(struct quota_root_iter *iter);
5566
88307a648e0e Use sync_notify() callback to count expunges. This makes the calculation
Timo Sirainen <tss@iki.fi>
parents: 4844
diff changeset
38 void quota_root_iter_deinit(struct quota_root_iter **iter);
3738
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
39
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
40 /* Return quota root or NULL. */
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
41 struct quota_root *quota_root_lookup(struct quota *quota, const char *name);
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
42
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
43 /* Returns name of the quota root. */
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
44 const char *quota_root_get_name(struct quota_root *root);
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
45 /* Return a list of all resources set for the quota root. */
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
46 const char *const *quota_root_get_resources(struct quota_root *root);
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
47
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
48 /* Returns 1 if quota value was found, 0 if not, -1 if error. */
4509
e5e79558ac2d Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4330
diff changeset
49 int quota_get_resource(struct quota_root *root, const char *mailbox_name,
3738
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
50 const char *name, uint64_t *value_r, uint64_t *limit_r);
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
51 /* Returns 0 if OK, -1 if error (eg. permission denied, invalid name). */
4509
e5e79558ac2d Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4330
diff changeset
52 int quota_set_resource(struct quota_root *root, const char *name,
e5e79558ac2d Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4330
diff changeset
53 uint64_t value, const char **error_r);
3738
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
54
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
55 /* Start a new quota transaction. */
4509
e5e79558ac2d Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4330
diff changeset
56 struct quota_transaction_context *quota_transaction_begin(struct quota *quota,
e5e79558ac2d Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4330
diff changeset
57 struct mailbox *box);
3738
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
58 /* Commit quota transaction. Returns 0 if ok, -1 if failed. */
5566
88307a648e0e Use sync_notify() callback to count expunges. This makes the calculation
Timo Sirainen <tss@iki.fi>
parents: 4844
diff changeset
59 int quota_transaction_commit(struct quota_transaction_context **ctx);
3738
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
60 /* Rollback quota transaction changes. */
5566
88307a648e0e Use sync_notify() callback to count expunges. This makes the calculation
Timo Sirainen <tss@iki.fi>
parents: 4844
diff changeset
61 void quota_transaction_rollback(struct quota_transaction_context **ctx);
3738
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
62
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
63 /* Allocate from quota if there's space. Returns 1 if updated, 0 if not,
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
64 -1 if error. If mail size is larger than even maximum allowed quota,
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
65 too_large_r is set to TRUE. */
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
66 int quota_try_alloc(struct quota_transaction_context *ctx,
3863
55df57c028d4 Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents: 3738
diff changeset
67 struct mail *mail, bool *too_large_r);
4509
e5e79558ac2d Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4330
diff changeset
68 /* Like quota_try_alloc(), but don't actually allocate anything. */
e5e79558ac2d Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4330
diff changeset
69 int quota_test_alloc(struct quota_transaction_context *ctx,
e5e79558ac2d Added support for multiple quota roots, rules and storages. The configuration
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4330
diff changeset
70 uoff_t size, bool *too_large_r);
3738
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
71 /* Update quota by allocating/freeing space used by mail. */
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
72 void quota_alloc(struct quota_transaction_context *ctx, struct mail *mail);
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
73 void quota_free(struct quota_transaction_context *ctx, struct mail *mail);
5566
88307a648e0e Use sync_notify() callback to count expunges. This makes the calculation
Timo Sirainen <tss@iki.fi>
parents: 4844
diff changeset
74 void quota_free_bytes(struct quota_transaction_context *ctx,
88307a648e0e Use sync_notify() callback to count expunges. This makes the calculation
Timo Sirainen <tss@iki.fi>
parents: 4844
diff changeset
75 uoff_t physical_size);
88307a648e0e Use sync_notify() callback to count expunges. This makes the calculation
Timo Sirainen <tss@iki.fi>
parents: 4844
diff changeset
76 /* Mark the quota to be recalculated */
88307a648e0e Use sync_notify() callback to count expunges. This makes the calculation
Timo Sirainen <tss@iki.fi>
parents: 4844
diff changeset
77 void quota_recalculate(struct quota_transaction_context *ctx);
3738
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
78
732b62dc1976 Added beginnings of plugin infrastructure. TODO: These could be optionally
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
79 #endif