-
Notifications
You must be signed in to change notification settings - Fork 4
/
config.h
82 lines (69 loc) · 1.28 KB
/
config.h
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#ifndef CONFIG_H
#define CONFIG_H
#include "array.h"
#include <string.h>
struct thread_contex_s;
enum {
HASH_ONE_AT_A_TIME = 0,
HASH_MD5,
HASH_CRC16,
HASH_CRC32,
HASH_CRC32A,
HASH_FNV1_64,
HASH_FNV1A_64,
HASH_FNV1_32,
HASH_FNV1A_32,
HASH_HSIEH,
HASH_MURMUR,
HASH_JENKINS
};
enum {
DIST_KETAMA = 0,
DIST_MODULA,
DIST_RANDOM
};
typedef struct{
char * name;
int kind;
}hashType;
typedef struct{
char * name;
int kind;
}distributionType;
typedef struct{
uint32_t value;
int index;
}continuum;
typedef struct{
int hashType;
int distType;
array * servers;
continuum * con;
int ncontinuum;
char auth[100];
}config;
typedef struct{
int weight;
char pname[100];
int pname_length;
char name[100];
int name_length;
int port;
struct thread_contex_s * contex;
}server_conf;
config * loadFromFile(const char * file);
void loadConfig(const char * file);
static int toNumber(char *p ,char *q){
int value = 0;
for (; p < q ; p++) {
if (*p < '0' || *p > '9') {
return -1;
}
value = value * 10 + (*p - '0');
}
if (value < 0) {
return -1;
}
return value;
}
#endif