summaryrefslogtreecommitdiffstats
path: root/web/attachments/136655-nagiosplug-common_h-sanity.diff
blob: 187f298a95b7ca98958741fe7b78dd69f07c11ad (plain)
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
diff -urN ../orig.nplg/plugins/common.h ./plugins/common.h
--- ../orig.nplg/plugins/common.h	2004-12-10 11:42:00.000000000 +0100
+++ ./plugins/common.h	2005-05-31 14:34:48.000000000 +0200
@@ -32,7 +32,17 @@
  *
  *****************************************************************************/
 
-#include "config.h"
+#ifndef NAGIOSPLUG_COMMON_H
+#define NAGIOSPLUG_COMMON_H
+
+/* For non-GNU compilers to ignore __attribute__
+ * This must be here so that imported GNU headers can be used with non-gnu
+ * compilers and so we can safely (and properly) put prototypes here. */
+#ifndef __GNUC__
+# define __attribute__(x) /* do nothing */
+#endif
+
+# include "config.h"
 
 #ifdef HAVE_FEATURES_H
 #include <features.h>
@@ -131,19 +141,25 @@
 #endif
 
 #ifndef HAVE_ASPRINTF
-int asprintf(char **strp, const char *fmt, ...);
+int asprintf(char **strp, const char *fmt, ...)
+	__attribute__((__format__(__printf__, 2, 3)));
 #endif
 
+/*
 #ifndef HAVE_VASPRINTF
-/* int vasprintf(char **strp, const char *fmt, va_list ap); */
+int vasprintf(char **strp, const char *fmt, va_list ap)
+	__attribute__((__format__(__printf__, 2, 0)));
 #endif
+*/
 
 #ifndef HAVE_SNPRINTF
-int snprintf(char *str, size_t size, const  char  *format, ...);
+int snprintf(char *str, size_t size, const  char  *format, ...)
+	__attribute__((__format__(__printf__, 3, 4)));
 #endif
 
 #ifndef HAVE_VSNPRINTF
-int vsnprintf(char *str, size_t size, const char  *format, va_list ap);
+int vsnprintf(char *str, size_t size, const char  *format, va_list ap)
+	__attribute__((__format__(__printf__, 3, 0)));
 #endif
 
 /*
@@ -152,32 +168,31 @@
  *
  */
 
-enum {
-	OK = 0,
-	ERROR = -1
-};
+/* These should be macros so they never have to be fetched
+ * from a different data-segment than the code evaluating it (which is
+ * bizarrely expensive on some weird architectures). It also makes it
+ * easier to develop and implement additional API's without mucking about
+ * with the "official" code (#ifdef STATE_CRITICAL etc).
+ */
+#define OK 0
+#define ERROR -1
 
 /* AIX seems to have this defined somewhere else */
 #ifndef FALSE
-enum {
-	FALSE,
-	TRUE
-};
-#endif
-
-enum {
-	STATE_OK,
-	STATE_WARNING,
-	STATE_CRITICAL,
-	STATE_UNKNOWN,
-	STATE_DEPENDENT
-};
-
-enum {
-	DEFAULT_SOCKET_TIMEOUT = 10,	 /* timeout after 10 seconds */
-	MAX_INPUT_BUFFER = 1024,	     /* max size of most buffers we use */
-	MAX_HOST_ADDRESS_LENGTH = 256	 /* max size of a host address */
-};
+# define FALSE 0
+# define TRUE 1
+#endif
+
+#define	STATE_OK 0
+#define STATE_WARNING 1
+#define STATE_CRITICAL 2
+#define STATE_UNKNOWN 3
+#define STATE_DEPENDENT 4
+#define STATE_OOB 5        /* status out of bounds. Must be last */
+
+#define DEFAULT_SOCKET_TIMEOUT 10    /* timeout after 10 seconds */
+#define MAX_INPUT_BUFFER 1024        /* max size of most buffers we use */
+#define MAX_HOST_ADDRESS_LENGTH 256	 /* max size of a host address */
 
 /*
  *
@@ -187,7 +202,4 @@
 #include "gettext.h"
 #define _(String) gettext (String)
 
-/* For non-GNU compilers to ignore __attribute__ */
-#ifndef __GNUC__
-# define __attribute__(x) /* do nothing */
-#endif
+#endif /* NAGIOSPLUG_COMMON_H */