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
122
123
124
125
126
127
|
/*
* stonith_plugin_common.h: common macros easing the writing of STONITH
* plugins. Only a STONITH plugin should
* include this header!
*
* Copyright (C) 2004 Lars Marowsky-Bree <lmb@suse.de>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef _STONITH_PLUGIN_COMMON_H
#define _STONITH_PLUGIN_COMMON_H
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <libintl.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/file.h>
#include <ctype.h>
#include <string.h>
#include <fcntl.h>
#include <netdb.h>
#ifdef HAVE_TERMIO_H
# include <termio.h>
#endif
#ifdef HAVE_SYS_TERMIOS_H
#include <sys/termios.h>
#else
#ifdef HAVE_TERMIOS_H
#include <termios.h>
#endif
#endif
#include <glib.h>
#include <stonith/stonith.h>
#include <stonith/stonith_plugin.h>
#define LOG(w...) PILCallLog(PluginImports->log, w)
#define MALLOC PluginImports->alloc
#define REALLOC PluginImports->mrealloc
#define STRDUP PluginImports->mstrdup
#define FREE PluginImports->mfree
#define EXPECT_TOK OurImports->ExpectToken
#define STARTPROC OurImports->StartProcess
#ifdef MALLOCT
# undef MALLOCT
#endif
#define ST_MALLOCT(t) ((t *)(MALLOC(sizeof(t))))
#define N_(text) (text)
#define _(text) dgettext(ST_TEXTDOMAIN, text)
#define WHITESPACE " \t\n\r\f"
#ifndef MIN
/* some macros */
# define MIN( i, j ) ( i > j ? j : i )
#endif
#define REPLSTR(s,v) { \
if ((s) != NULL) { \
FREE(s); \
(s)=NULL; \
} \
(s) = STRDUP(v); \
if ((s) == NULL) { \
PILCallLog(PluginImports->log, \
PIL_CRIT, "out of memory"); \
} \
}
#ifndef DEVICE
#define DEVICE "Dummy"
#endif
#define PIL_PLUGINTYPE STONITH_TYPE
#define PIL_PLUGINTYPE_S STONITH_TYPE_S
#define ISCORRECTDEV(i) ((i)!= NULL \
&& ((struct pluginDevice *)(i))->pluginid == pluginid)
#define ERRIFWRONGDEV(s, retval) if (!ISCORRECTDEV(s)) { \
LOG(PIL_CRIT, "%s: invalid argument", __FUNCTION__); \
return(retval); \
}
#define VOIDERRIFWRONGDEV(s) if (!ISCORRECTDEV(s)) { \
LOG(PIL_CRIT, "%s: invalid argument", __FUNCTION__); \
return; \
}
#define ISCONFIGED(i) (i->isconfigured)
#define ERRIFNOTCONFIGED(s,retval) ERRIFWRONGDEV(s,retval); \
if (!ISCONFIGED(s)) { \
LOG(PIL_CRIT, "%s: not configured", __FUNCTION__); \
return(retval); \
}
#define VOIDERRIFNOTCONFIGED(s) VOIDERRIFWRONGDEV(s); \
if (!ISCONFIGED(s)) { \
LOG(PIL_CRIT, "%s: not configured", __FUNCTION__); \
return; \
}
#endif
|