summaryrefslogtreecommitdiffstats
path: root/src/replication/replication-common.h
blob: 77f711c9ba2f32d693d8694966ce489f7f9f1b62 (plain)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#ifndef REPLICATION_COMMON_H
#define REPLICATION_COMMON_H

enum replication_priority {
	/* user is fully replicated, as far as we know */
	REPLICATION_PRIORITY_NONE = 0,
	/* flag changes, expunges, etc. */
	REPLICATION_PRIORITY_LOW,
	/* new emails */
	REPLICATION_PRIORITY_HIGH,
	/* synchronously wait for new emails to be replicated */
	REPLICATION_PRIORITY_SYNC
};

static inline const char *
replicator_priority_to_str(enum replication_priority priority)
{
	switch (priority) {
	case REPLICATION_PRIORITY_NONE:
		return "none";
	case REPLICATION_PRIORITY_LOW:
		return "low";
	case REPLICATION_PRIORITY_HIGH:
		return "high";
	case REPLICATION_PRIORITY_SYNC:
		return "sync";
	}
	i_unreached();
}

static inline int
replication_priority_parse(const char *str,
			   enum replication_priority *priority_r)
{
	if (strcmp(str, "none") == 0)
		*priority_r = REPLICATION_PRIORITY_NONE;
	else if (strcmp(str, "low") == 0)
		*priority_r = REPLICATION_PRIORITY_LOW;
	else if (strcmp(str, "high") == 0)
		*priority_r = REPLICATION_PRIORITY_HIGH;
	else if (strcmp(str, "sync") == 0)
		*priority_r = REPLICATION_PRIORITY_SYNC;
	else
		return -1;
	return 0;
}

#endif