summaryrefslogtreecommitdiff
path: root/pkgtools/libnbcompat/files/nbcompat.h
diff options
context:
space:
mode:
authorjlam <jlam@pkgsrc.org>2003-09-01 15:31:14 +0000
committerjlam <jlam@pkgsrc.org>2003-09-01 15:31:14 +0000
commit0c71abea7bc5069ad2801f22018009cf6fbbe310 (patch)
tree6c33504ee3cc8d5859f915b04dd4544806e3ebda /pkgtools/libnbcompat/files/nbcompat.h
parent6c83902dd76746c1b48020a7392808ea514fdaa5 (diff)
downloadpkgsrc-0c71abea7bc5069ad2801f22018009cf6fbbe310.tar.gz
Bump version to 20030823:
* Add mkdtemp, TAILQ_*, and statfs. * Install a nbconfig.h file containing the discovered system information and include it directly in nbcompat.h. Make all files use nbconfig.h instead of config.h. Ensure that all installed headers don't include any local header files. This makes libnbcompat more self-contained. * Consistently use "#if HAVE_HEADER_H" instead of "#ifdef HAVE_HEADER_H" since sometimes people put -DHAVE_HEADER_H=0 on their command lines.
Diffstat (limited to 'pkgtools/libnbcompat/files/nbcompat.h')
-rw-r--r--pkgtools/libnbcompat/files/nbcompat.h72
1 files changed, 69 insertions, 3 deletions
diff --git a/pkgtools/libnbcompat/files/nbcompat.h b/pkgtools/libnbcompat/files/nbcompat.h
index 97e6a954e10..c0a2a2c5614 100644
--- a/pkgtools/libnbcompat/files/nbcompat.h
+++ b/pkgtools/libnbcompat/files/nbcompat.h
@@ -1,7 +1,7 @@
#ifndef _NBCOMPAT_H
#define _NBCOMPAT_H
-#include "config.h"
+#include <nbconfig.h>
#include <nbtypes.h>
@@ -117,6 +117,68 @@ struct { \
#define LIST_NEXT(elm, field) ((elm)->field.le_next)
#endif
+#if HAVE_SYS_QUEUE_H
+# include <sys/queue.h>
+#else
+#define TAILQ_HEAD(name, type) \
+struct name { \
+ struct type *tqh_first; /* first element */ \
+ struct type **tqh_last; /* addr of last next element */ \
+}
+
+#define TAILQ_HEAD_INITIALIZER(head) \
+ { NULL, &(head).tqh_first }
+
+#define TAILQ_ENTRY(type) \
+struct { \
+ struct type *tqe_next; /* next element */ \
+ struct type **tqe_prev; /* address of previous next element */ \
+}
+
+#define TAILQ_INIT(head) do { \
+ (head)->tqh_first = NULL; \
+ (head)->tqh_last = &(head)->tqh_first; \
+} while (/*CONSTCOND*/0)
+
+#define TAILQ_INSERT_HEAD(head, elm, field) do { \
+ if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \
+ (head)->tqh_first->field.tqe_prev = \
+ &(elm)->field.tqe_next; \
+ else \
+ (head)->tqh_last = &(elm)->field.tqe_next; \
+ (head)->tqh_first = (elm); \
+ (elm)->field.tqe_prev = &(head)->tqh_first; \
+} while (/*CONSTCOND*/0)
+
+#define TAILQ_INSERT_TAIL(head, elm, field) do { \
+ (elm)->field.tqe_next = NULL; \
+ (elm)->field.tqe_prev = (head)->tqh_last; \
+ *(head)->tqh_last = (elm); \
+ (head)->tqh_last = &(elm)->field.tqe_next; \
+} while (/*CONSTCOND*/0)
+
+#define TAILQ_REMOVE(head, elm, field) do { \
+ if (((elm)->field.tqe_next) != NULL) \
+ (elm)->field.tqe_next->field.tqe_prev = \
+ (elm)->field.tqe_prev; \
+ else \
+ (head)->tqh_last = (elm)->field.tqe_prev; \
+ *(elm)->field.tqe_prev = (elm)->field.tqe_next; \
+} while (/*CONSTCOND*/0)
+
+/*
+ * Tail queue access methods.
+ */
+#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL)
+#define TAILQ_FIRST(head) ((head)->tqh_first)
+#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
+
+#define TAILQ_FOREACH(var, head, field) \
+ for ((var) = ((head)->tqh_first); \
+ (var); \
+ (var) = ((var)->field.tqe_next))
+#endif
+
#if HAVE_ASSERT_H
# include <assert.h>
#endif
@@ -125,7 +187,7 @@ struct { \
# include <err.h>
#endif
-#include "ftpglob.h"
+#include <ftpglob.h>
#if HAVE_SYS_MKDEV_H
# include <sys/mkdev.h>
@@ -256,7 +318,7 @@ int pclose(FILE *);
#endif
#ifndef HAVE_ERR
-#include "err.h"
+#include <err.h>
#endif
#ifndef HAVE_FGETLN
@@ -288,6 +350,10 @@ int inet_pton(int, const char *, void *);
int mkstemp(char *);
#endif
+#ifndef HAVE_MKDTEMP
+char *mkdtemp(char *);
+#endif
+
#ifndef HAVE_LCHMOD
int lchmod(const char *, mode_t);
#endif