#ifndef __LIST_H__
#define __LIST_H__
//****************************************************************************
// Copyright (C) 2000-2004 ARW Elektronik Germany
//
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
// This product is not authorized for use as critical component in
// life support systems without the express written approval of
// ARW Elektronik Germany.
//
// Please announce changes and hints to ARW Elektronik
//
// Maintainer(s): Klaus Hitschler (klaus.hitschler@gmx.de)
//
//****************************************************************************
//****************************************************************************
//
// list.h - Header file for list.c
//
// $Log: list.h,v $
// Revision 1.5 2004/08/12 19:59:19 klaus
// conversion to kernel-version 2.6, released version 6.0
//
// Revision 1.4 2002/04/10 18:40:10 klaus
// compiled and modified on RedHat 7.2
//
// Revision 1.3 2001/11/20 20:12:50 klaus
// included new header and CVS log
//
//
// derived from code original by Dirk Muehlenberg AR 18.02.2000
// removed all ANEW, FREE because of MODVERSIONS AR 24.04.2000
//
//****************************************************************************
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)
#include <linux/malloc.h>
#else
#include <linux/slab.h>
#endif
typedef struct _node
{
struct _node *pred; /* points to previous */
struct _node *succ; /* points to next */
void *data; /* points to work load */
} Node;
typedef struct _list
{
Node *head; /* points to head of list */
Node *tail; /* points to tail of list */
int nodes; /* current number of nodes */
} List;
enum NodePosition {CurrentLeft, CurrentRight};
/*-- PROTOTYPES ----------------------------------------------------------------------*/
Node *initNode(void);
Node *addNode(Node *, void *, enum NodePosition);
Node *delNode(Node *);
List *newList(void);
void deleteList(List *, void (*)(void *));
Node *addTail(List *, void *);
Node *addHead(List *, void *);
Node *searchList(List *, void *, int (*)(void *, void *));
void delNodeInList(List *, Node *);
void delNodeAndDataInList(List *, Node *);
void delTail(List *);
void delTailAndData(List *);
void resetList(List *, void (*)(void *));
void printList(List *, char *(*)(void *));
#ifndef USE_MACROS
int getNumOfNodesInList(List *);
#else
#define getNumOfNodesInList(l) l->nodes
#endif
int emptyList(List *);
/* for lifo-, fifo operations */
Node *getFirstNode(List *);
Node *getNextNode(Node *);
Node *getPrevNode(Node *);
Node *getLastNode(List *);
void *getContent(Node *n);
void delFirstNode(List *);
void delFirstNodeAndData(List *);
void delLastNode(List *);
void delLastNodeAndData(List *);
#endif /* __LIST_H__ */