#define IMOD(i, j) (((i) % (j)) < 0 ? ((i) % (j))+(j) : ((i) % (j)))
#define IN_RANGE(n, lo, hi) ((lo) <= (n) && (n) <= (hi))
#define LOOPDN(r, n) for ((r) = (n)+1; --(r) > 0;)
-#define MAX(x, y) (((x) < (y)) ? (y) : (x))
+#ifndef MAX
+# define MAX(x, y) (((x) < (y)) ? (y) : (x))
+#endif
#ifndef max
-#define max(x, y) (((x) < (y)) ? (y) : (x))
+# define max(x, y) (((x) < (y)) ? (y) : (x))
+#endif
+#ifndef MIN
+# define MIN(x, y) (((x) < (y)) ? (x) : (y))
#endif
-#define MIN(x, y) (((x) < (y)) ? (x) : (y))
#ifndef min
-#define min(x, y) (((x) < (y)) ? (x) : (y))
+# define min(x, y) (((x) < (y)) ? (x) : (y))
#endif
#define STREQ(s, t) (strcmp(s, t) == 0)
#define STRGT(s, t) (strcmp(s, t) > 0)
char *rptstrip(char *);
char *rptfmt(char *);
char *rptfmti(char *, unsigned short int);
-
+
+#ifndef __FreeBSD__ // strnstr is already defined on FreeBSD
char *strnstr(char *, char *, size_t);
+#endif
int stregion(int);
int ccregion(char *);