From f56dcd2b76ac8406a382c5c121393663bfa5f654 Mon Sep 17 00:00:00 2001 From: Emil Mikulic Date: Sat, 28 Jun 2003 04:13:19 +0000 Subject: [PATCH] Borged parts of sys/queue.h since non-BSDs don't have the header. --- trunk/darkhttpd.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/trunk/darkhttpd.c b/trunk/darkhttpd.c index 6349beb..5d8a29d 100644 --- a/trunk/darkhttpd.c +++ b/trunk/darkhttpd.c @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include @@ -55,6 +54,63 @@ #define min(a,b) ( ((a)<(b)) ? (a) : (b) ) #endif + + +/* --------------------------------------------------------------------------- + * LIST_* macros taken from FreeBSD's src/sys/sys/queue.h,v 1.32.2.7 + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Under a BSD license. + */ + +#define LIST_HEAD(name, type) \ +struct name { \ + struct type *lh_first; /* first element */ \ +} + +#define LIST_HEAD_INITIALIZER(head) \ + { NULL } + +#define LIST_ENTRY(type) \ +struct { \ + struct type *le_next; /* next element */ \ + struct type **le_prev; /* address of previous next element */ \ +} + +#define LIST_EMPTY(head) ((head)->lh_first == NULL) + +#define LIST_FIRST(head) ((head)->lh_first) + +#define LIST_FOREACH(var, head, field) \ + for ((var) = LIST_FIRST((head)); \ + (var); \ + (var) = LIST_NEXT((var), field)) + +#define LIST_INIT(head) do { \ + LIST_FIRST((head)) = NULL; \ +} while (0) + +#define LIST_INSERT_HEAD(head, elm, field) do { \ + if ((LIST_NEXT((elm), field) = LIST_FIRST((head))) != NULL) \ + LIST_FIRST((head))->field.le_prev = &LIST_NEXT((elm), field);\ + LIST_FIRST((head)) = (elm); \ + (elm)->field.le_prev = &LIST_FIRST((head)); \ +} while (0) + +#define LIST_NEXT(elm, field) ((elm)->field.le_next) + +#define LIST_REMOVE(elm, field) do { \ + if (LIST_NEXT((elm), field) != NULL) \ + LIST_NEXT((elm), field)->field.le_prev = \ + (elm)->field.le_prev; \ + *(elm)->field.le_prev = LIST_NEXT((elm), field); \ +} while (0) + +/* ------------------------------------------------------------------------ */ + + + LIST_HEAD(conn_list_head, connection) connlist = LIST_HEAD_INITIALIZER(conn_list_head);