showlog: Start implementing state-based filtering
[nagios-reports-module.git] / ndbneb.h
blobef131e88d8241e966b7b3ce6806aa67d0fdb58c9
1 /*
2 * globally useful cruft goes here
3 */
5 #ifndef _NDBNEB_H_
6 #define _NDBNEB_H_
8 #define _GNU_SOURCE 1
10 #include <stdio.h>
12 #ifndef __GNUC__
13 # define __attribute__(x)
14 #endif
16 #define prefixcmp(a, b) strncmp(a, b, strlen(b))
18 #ifndef ARRAY_SIZE
19 # define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
20 #endif
22 #ifndef ISSPACE
23 # define ISSPACE(c) (c == ' ' || c == '\t')
24 #endif
27 * finds the next word in a comma-separated list.
28 * if there are multiple commas between each word,
29 * it will return a pointer to the second one
31 static inline char *next_word(char *str)
33 while (*str && *str != ',' && !ISSPACE(*str))
34 str++;
36 if (!*str)
37 return NULL;
39 do {
40 while (ISSPACE(*str))
41 str++;
43 if (*str == ',') {
44 str++;
45 while (ISSPACE(*str))
46 str++;
47 break;
49 } while (*str++);
51 if (*str)
52 return str;
54 return NULL;
56 #endif