• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • Directories
  • File List
  • Globals

clist.h

Go to the documentation of this file.
00001 /*
00002  * $Id$
00003  *
00004  * circular list maintenance macros
00005  *
00006  * Copyright (C) 2005 iptelorg GmbH
00007  *
00008  * This file is part of ser, a free SIP server.
00009  *
00010  * ser is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version
00014  *
00015  * ser is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License 
00021  * along with this program; if not, write to the Free Software 
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023  */
00024 
00033 /* History:
00034  * --------
00035  *  2005-08-08  created by andrei
00036  */
00037 
00038 #ifndef _clist_h
00039 #define _clist_h
00040 
00042 #define clist_init(c, next, prev) \
00043         do{ \
00044                 (c)->next=(void*)(c); \
00045                 (c)->prev=(void*)(c); \
00046         } while(0)
00047 
00048 
00049 
00058 #define clist_insert_sublist(head, s, e, next, prev) \
00059         do{ \
00060                 (s)->prev=(void*)(head); \
00061                 (e)->next=(head)->next; \
00062                 (e)->next->prev=(e); \
00063                 (head)->next=s;   \
00064         }while(0)
00065 
00066 
00067 
00075 #define clist_append_sublist(head, s, e, next, prev) \
00076         do{ \
00077                 (s)->prev=(head)->prev; \
00078                 (e)->next=(void*)(head); \
00079                 (s)->prev->next=(s); \
00080                 (head)->prev=(e);   \
00081         }while(0)
00082 
00083 
00084 
00085 
00092 #define clist_rm_sublist(s, e, next, prev) \
00093         do{\
00094                 (s)->prev->next=(e)->next;  \
00095                 (e)->next->prev=(s)->prev ; \
00096         }while(0)
00097 
00098 
00099 
00101 #define clist_insert(head, c, next, prev) \
00102         clist_insert_sublist(head, c, c, next, prev)
00103 
00104 
00105 
00107 #define clist_append(head, c, next, prev) \
00108         clist_append_sublist(head, c, c, next, prev)
00109 
00110 
00111 
00113 #define clist_rm(c, next, prev) \
00114         clist_rm_sublist(c, c, next, prev)
00115 
00116 
00117 
00119 #define clist_foreach(head, v, dir) \
00120         for((v)=(head)->dir; (v)!=(void*)(head); (v)=(v)->dir)
00121 
00124 #define clist_foreach_safe(head, v, bak,  dir) \
00125         for((v)=(head)->dir, (bak)=(v)->dir; (v)!=(void*)(head); \
00126                                 (v)=(bak), (bak)=(v)->dir)
00127 #endif

Generated on Tue May 22 2012 13:10:04 for SIP Router by  doxygen 1.7.1