-
Notifications
You must be signed in to change notification settings - Fork 0
/
global.h
89 lines (74 loc) · 2.8 KB
/
global.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
83
84
85
86
87
88
#ifndef __DISPATCHER_GLOBAL_H__
#define __DISPATCHER_GLOBAL_H__
#include "dispatcher.h"
/* define supported facilites in configuration file */
dp_enum dp_log_facility[] = {
{"LOG_USER", LOG_USER},
{"LOG_DAEMON", LOG_DAEMON},
{"LOG_LOCAL0", LOG_LOCAL0},
{"LOG_LOCAL1", LOG_LOCAL1},
{"LOG_LOCAL2", LOG_LOCAL2},
{"LOG_LOCAL3", LOG_LOCAL3},
{"LOG_LOCAL4", LOG_LOCAL4},
{"LOG_LOCAL5", LOG_LOCAL5},
{"LOG_LOCAL6", LOG_LOCAL6},
{"LOG_LOCAL7", LOG_LOCAL7},
{NULL, 0}
};
/* define supported levels in configuration file */
dp_enum dp_log_level[] = {
{"LOG_EMERG", LOG_EMERG},
{"LOG_ALERT", LOG_ALERT},
{"LOG_CRIT", LOG_CRIT},
{"LOG_ERR", LOG_ERR},
{"LOG_WARNING", LOG_WARNING},
{"LOG_NOTICE", LOG_NOTICE},
{"LOG_INFO", LOG_INFO},
{"LOG_DEBUG", LOG_DEBUG},
{NULL, 0}
};
dp_enum dp_config_value[] = {
{"mysql_host", DP_CONFIG_MYSQL_HOST},
{"mysql_db", DP_CONFIG_MYSQL_DB},
{"mysql_user", DP_CONFIG_MYSQL_USER},
{"mysql_passwd", DP_CONFIG_MYSQL_PASSWD},
{"mysql_table", DP_CONFIG_MYSQL_TABLE},
{"mysql_port", DP_CONFIG_MYSQL_PORT},
{"gearman_host", DP_CONFIG_GEARMAN_HOST},
{"gearman_port", DP_CONFIG_GEARMAN_PORT},
{"task_failed_delay", DP_CONFIG_TASK_FAILED_DELAY},
{"task_timeout_delay", DP_CONFIG_TASK_TIMEOUT_DELAY},
{"task_environment", DP_CONFIG_TASK_ENVIRONMENT},
{"task_priority", DP_CONFIG_TASK_PRIORITY},
{"log_dispatcher", DP_CONFIG_LOG_DISPATCHER},
{"log_worker", DP_CONFIG_LOG_WORKER},
{"log_level", DP_CONFIG_LOG_LEVEL},
{"log_facility", DP_CONFIG_LOG_FACILITY},
{"sense_loop", DP_CONFIG_SENSE_LOOP},
{"sense_terminated", DP_CONFIG_SENSE_TERMINATED},
{"sense_paused", DP_CONFIG_SENSE_PAUSED},
{"sleep_loop", DP_CONFIG_SLEEP_LOOP},
{NULL, 0}
};
/* global flag to indicate child state change */
volatile sig_atomic_t child_flag = 0;
/* global flag to pause dispatching */
volatile sig_atomic_t pause_flag = 0;
/* global flag to terminate dispatcher */
volatile sig_atomic_t terminate_flag = 0;
/* global flag to reload configuration */
volatile sig_atomic_t reload_flag = 0;
/* global flag to output status */
volatile sig_atomic_t status_flag = 0;
/* global status variables */
int16_t child_counter = 0; /* current number of running children */
dp_child *child_status = NULL; /* array of child status */
uint8_t child_limit = 50; /* maximum number of children */
/* global configuration */
const char *cfg_location = NULL; /* configuration file location override */
dp_config cfg; /* global configuration object */
/* global state flags */
bool initialized = false; /* flag to indicate basic initialization */
/* global buffers */
dp_buffer *query = NULL; /* query buffer */
#endif /* !__DISPATCHER_GLOBAL_H__ */