Licensing: Update copyright dates for Ian Jackson
[adns] / src / dlist.h
CommitLineData
70ad7a2a 1/*
2 * dlist.h
3 * - macros for handling doubly linked lists
4 */
5/*
ae8cc977 6 * This file is part of adns, which is
26e1c3d6 7 * Copyright (C) 1997-2000,2003,2006,2014 Ian Jackson
ae8cc977 8 * Copyright (C) 1999-2000,2003,2006 Tony Finch
9 * Copyright (C) 1991 Massachusetts Institute of Technology
10 * (See the file INSTALL for full details.)
70ad7a2a 11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
7f8bbe29 14 * the Free Software Foundation; either version 3, or (at your option)
70ad7a2a 15 * any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
8c09a4c6 23 * along with this program; if not, write to the Free Software Foundation.
70ad7a2a 24 */
25
26#ifndef ADNS_DLIST_H_INCLUDED
27#define ADNS_DLIST_H_INCLUDED
28
29#define LIST_INIT(list) ((list).head= (list).tail= 0)
30#define LINK_INIT(link) ((link).next= (link).back= 0)
31
609133ee 32#define LIST_UNLINK_PART(list,node,part) \
33 do { \
70ad7a2a 34 if ((node)->part back) (node)->part back->part next= (node)->part next; \
35 else (list).head= (node)->part next; \
36 if ((node)->part next) (node)->part next->part back= (node)->part back; \
37 else (list).tail= (node)->part back; \
38 } while(0)
39
609133ee 40#define LIST_LINK_TAIL_PART(list,node,part) \
41 do { \
42 (node)->part next= 0; \
43 (node)->part back= (list).tail; \
44 if ((list).tail) (list).tail->part next= (node); \
45 else (list).head= (node); \
46 (list).tail= (node); \
70ad7a2a 47 } while(0)
48
49#define LIST_UNLINK(list,node) LIST_UNLINK_PART(list,node,)
50#define LIST_LINK_TAIL(list,node) LIST_LINK_TAIL_PART(list,node,)
51
52#endif