diff options
-rw-r--r-- | plugins/common.h | 87 |
1 files changed, 23 insertions, 64 deletions
diff --git a/plugins/common.h b/plugins/common.h index 56d53761..af979525 100644 --- a/plugins/common.h +++ b/plugins/common.h | |||
@@ -120,67 +120,26 @@ int vsnprintf(char *str, size_t size, const char *format, va_list ap); | |||
120 | * | 120 | * |
121 | */ | 121 | */ |
122 | 122 | ||
123 | #define OK 0 | 123 | enum { |
124 | #define ERROR -1 | 124 | OK = 0, |
125 | 125 | ERROR = -1 | |
126 | #define TRUE 1 | 126 | }; |
127 | #define FALSE 0 | 127 | |
128 | 128 | enum { | |
129 | #define STATE_CRITICAL 2 /* service state return codes */ | 129 | FALSE, |
130 | #define STATE_WARNING 1 | 130 | TRUE |
131 | #define STATE_OK 0 | 131 | }; |
132 | #define STATE_UNKNOWN 3 | 132 | |
133 | #define STATE_DEPENDENT 4 | 133 | enum { |
134 | 134 | STATE_OK, | |
135 | #define DEFAULT_SOCKET_TIMEOUT 10 /* timeout after 10 seconds */ | 135 | STATE_WARNING, |
136 | 136 | STATE_CRITICAL, | |
137 | #define MAX_INPUT_BUFFER 1024 /* max size of most buffers we use */ | 137 | STATE_UNKNOWN, |
138 | 138 | STATE_DEPENDENT | |
139 | #define MAX_HOST_ADDRESS_LENGTH 256 /* max size of a host address */ | 139 | }; |
140 | 140 | ||
141 | 141 | enum { | |
142 | #ifndef HAVE_SNPRINTF | 142 | DEFAULT_SOCKET_TIMEOUT = 10, /* timeout after 10 seconds */ |
143 | /* | 143 | MAX_INPUT_BUFFER = 1024, /* max size of most buffers we use */ |
144 | int snprintf (char *str, size_t n, const char *fmt, ...); | 144 | MAX_HOST_ADDRESS_LENGTH = 256 /* max size of a host address */ |
145 | int snprintf (char *str, size_t n, const char *fmt, ...) | 145 | }; |
146 | { | ||
147 | char *buf; | ||
148 | int i; | ||
149 | int j=0; | ||
150 | va_list ap; | ||
151 | int d; | ||
152 | char c, *p, *s; | ||
153 | |||
154 | if((buf=malloc(n))==NULL){ | ||
155 | puts("could not malloc snprintf buffer\n"); | ||
156 | exit(-1); | ||
157 | } | ||
158 | va_start(ap,fmt); | ||
159 | i=strlen(fmt); | ||
160 | while((jj=index(&fmt[j],'%'))){ | ||
161 | j+=jj+1; | ||
162 | switch fmt[j] | ||
163 | { | ||
164 | case 's': | ||
165 | s = va_arg(ap, char *); | ||
166 | i+=strlen(s); | ||
167 | break; | ||
168 | case 'd': | ||
169 | d = va_arg(ap, int); | ||
170 | i++; | ||
171 | if (d<0) i++; | ||
172 | while((d=d/10)>0) i++; | ||
173 | break; | ||
174 | case 'c': | ||
175 | c = va_arg(ap, char); | ||
176 | i++; | ||
177 | break; | ||
178 | } | ||
179 | } | ||
180 | va_end(ap); | ||
181 | vsprintf(buf,fmt,ap); | ||
182 | strcpy(str,buf[1:n-1]); | ||
183 | exit(result); | ||
184 | } | ||
185 | */ | ||
186 | #endif | ||