summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKarl DeBisschop <kdebisschop@users.sourceforge.net>2003-03-18 07:57:00 (GMT)
committerKarl DeBisschop <kdebisschop@users.sourceforge.net>2003-03-18 07:57:00 (GMT)
commit338f51f76e7c1b425e288dd8a924768552cc38ab (patch)
treea176be3ff93e1e0443b20d7032c784f2f897a011 /plugins
parent18270bf20a930f713850fb8c2efa20b2a0f212c1 (diff)
downloadmonitoring-plugins-338f51f76e7c1b425e288dd8a924768552cc38ab.tar.gz
use enum instead of define, remove some cruft from old snprintf implementation
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@431 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/common.h87
1 files changed, 23 insertions, 64 deletions
diff --git a/plugins/common.h b/plugins/common.h
index 56d5376..af97952 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 123enum {
124#define ERROR -1 124 OK = 0,
125 125 ERROR = -1
126#define TRUE 1 126};
127#define FALSE 0 127
128 128enum {
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 133enum {
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 141enum {
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 */
144int snprintf (char *str, size_t n, const char *fmt, ...); 144 MAX_HOST_ADDRESS_LENGTH = 256 /* max size of a host address */
145int 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