-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmysch_struct.h
121 lines (98 loc) · 3.49 KB
/
mysch_struct.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/*
* mysch_struct.h
*
* Created on: 2014-5-29
* Author: Luo Guochun
*/
#ifndef __MYSCH_STRUCT_H__
#define __MYSCH_STRUCT_H__
#include "dlist.h"
#include "dict.h"
#define REGISTER_SIGNAL(signo, func, interupt) \
do { \
if(set_signal(signo, func, interupt) == SIG_ERR){ \
printf("register signal %d failed:%s\n", \
signo, strerror(errno)); \
return -1; \
} \
}while(0)
#define READ_CONF_INT_MUST(s, k, v) \
do{ \
const char* t = ini_get_val(s, k); \
if(NULL == t){ \
printf("fail to obtain configuration item." \
" item: %s\n", k); \
return -1; \
}else{ \
v = atoi(t); \
} \
}while(0)
#define READ_CONF_INT_OPT(s, k, v) \
do{ \
const char* t = ini_get_val(s, k); \
if(NULL != t){ \
v = atoi(t); \
} \
}while(0)
#define READ_CONF_STR_MUST(s, k, v) \
do{ \
const char* t = ini_get_val(s, k); \
if(NULL == t){ \
printf("fail to obtain configuration item." \
" item: %s\n", k); \
return -1; \
}else{ \
/*必须确保V比T空间大*/ \
strcpy(v, t); \
} \
}while(0)
#define READ_CONF_STR_OPT(s, k, v) \
do{ \
const char* t = ini_get_val(s, k); \
if(NULL != t){ \
/*必须确保V比T空间大*/ \
strcpy(v, t); \
} \
}while(0)
#define FORK_FIRST (-1)
#define FORK_ONCE (0)
#define FORK_WATCH (1)
#define FORK_PERIOD (2)
typedef struct prog_s prog_t;
typedef struct cond_s cond_t;
typedef struct sch_info_s sch_info_t;
typedef struct list cond_group_t;
typedef struct list prog_group_t;
typedef struct dict prog_wait_t;
struct prog_s
{
pid_t pid;
int update_pid;
int has_pid_file;
char pid_file[256];
char cmd[256];
int argc;
char argv[16][128];
char user[64];
int flag;
cond_group_t* cond;
int status;
long time;
};
struct cond_s
{
char day[7 + 1];
long start;
long end;
};
struct sch_info_s
{
int sleep_time;
int kill_flag;
char pid_file[256];
char run_user[64];
char conf[256];
prog_group_t* progq;
prog_wait_t* waitq;
};
#endif /* __MYSCH_STRUCT_H__ */