lib/cds/list.h

00001 /* 
00002  * Copyright (C) 2005 iptelorg GmbH
00003  *
00004  * This file is part of ser, a free SIP server.
00005  *
00006  * ser is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version
00010  *
00011  * For a license to use the ser software under conditions
00012  * other than those described here, or to purchase support for this
00013  * software, please contact iptel.org by e-mail at the following addresses:
00014  *    info@iptel.org
00015  *
00016  * ser is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License
00022  * along with this program; if not, write to the Free Software
00023  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00024  */
00025 
00026 #ifndef __LIST_H
00027 #define __LIST_H
00028 
00029 #define DOUBLE_LINKED_LIST_ADD(first,last,e)    do { \
00030                 if (last) last->next = (e); \
00031                 else first = (e); \
00032                 (e)->next = NULL; \
00033                 (e)->prev = last; \
00034                 last = (e); \
00035         } while (0)
00036 
00037 #define DOUBLE_LINKED_LIST_REMOVE(first,last,e) do { \
00038                 if ((e)->next) (e)->next->prev = (e)->prev; \
00039                 else last = (e)->prev; \
00040                 if ((e)->prev) (e)->prev->next = (e)->next; \
00041                 else first = (e)->next; \
00042                 (e)->next = NULL; \
00043                 (e)->prev = NULL; \
00044         } while (0)
00045 
00046 #define LINKED_LIST_ADD(first,last,e)   do { \
00047                 if (last) last->next = (e); \
00048                 else first = (e); \
00049                 (e)->next = NULL; \
00050                 last = (e); \
00051         } while (0)
00052 
00053 #endif