Main Page | Modules | Data Structures | File List | Data Fields | Globals | Examples

list.h

Go to the documentation of this file.
00001 /**
00002  * \addtogroup list
00003  * @{
00004  */
00005 
00006 /**
00007  * \file
00008  * Linked list manipulation routines.
00009  * \author Adam Dunkels <adam@sics.se>
00010  *
00011  *
00012  */
00013 
00014 
00015 
00016 /*
00017  * Copyright (c) 2004, Swedish Institute of Computer Science.
00018  * All rights reserved. 
00019  *
00020  * Redistribution and use in source and binary forms, with or without 
00021  * modification, are permitted provided that the following conditions 
00022  * are met: 
00023  * 1. Redistributions of source code must retain the above copyright 
00024  *    notice, this list of conditions and the following disclaimer. 
00025  * 2. Redistributions in binary form must reproduce the above copyright 
00026  *    notice, this list of conditions and the following disclaimer in the 
00027  *    documentation and/or other materials provided with the distribution. 
00028  * 3. Neither the name of the Institute nor the names of its contributors 
00029  *    may be used to endorse or promote products derived from this software 
00030  *    without specific prior written permission. 
00031  *
00032  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
00033  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
00034  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
00035  * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
00036  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
00037  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
00038  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
00039  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
00040  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
00041  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
00042  * SUCH DAMAGE. 
00043  *
00044  * This file is part of the Contiki operating system.
00045  * 
00046  * Author: Adam Dunkels <adam@sics.se>
00047  *
00048  * $Id: list.h,v 1.3 2005/03/08 11:47:24 adam Exp $
00049  */
00050 #ifndef __LIST_H__
00051 #define __LIST_H__
00052 
00053 #define LIST_CONCAT2(s1, s2) s1##s2
00054 #define LIST_CONCAT(s1, s2) LIST_CONCAT2(s1, s2)
00055 
00056 /**
00057  * Declare a linked list.
00058  *
00059  * This macro declares a linked list with the specified \c type. The
00060  * type \b must be a structure (\c struct) with its first element
00061  * being a pointer. This pointer is used by the linked list library to
00062  * form the linked lists.
00063  *
00064  * Example
00065  \code
00066 
00067  struct packet * {
00068    struct packet *next;
00069    char data[1500];
00070  };
00071  
00072  LIST(packets);
00073  \endcode
00074  *
00075  * \param name The name of the list.
00076  */
00077 #define LIST(name) \
00078          static void *LIST_CONCAT(name,_list) = NULL; \
00079          static list_t name = (list_t)&LIST_CONCAT(name,_list)
00080 
00081 /**
00082  * The linked list type.
00083  *
00084  */
00085 typedef void ** list_t;
00086 
00087 void  list_init(list_t list);
00088 void *list_head(list_t list);
00089 void *list_tail(list_t list);
00090 void *list_pop (list_t list);
00091 void  list_push(list_t list, void *item);
00092 
00093 void *list_chop(list_t list);
00094 
00095 void  list_add(list_t list, void *item);
00096 void  list_remove(list_t list, void *item);
00097 
00098 
00099 void  list_copy(list_t dest, list_t src);
00100 
00101 #endif /* __LIST_H__ */
00102 
00103 /** @} */

Generated on Wed Jul 6 01:18:59 2005 for Contiki/ESB by doxygen 1.3.6