Subversion Repositories f9daq

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
86 f9daq 1
#ifndef __LIST_H__
2
#define __LIST_H__
3
 
4
//****************************************************************************
5
// Copyright (C) 2000-2004  ARW Elektronik Germany
6
//
7
//
8
// This program is free software; you can redistribute it and/or modify
9
// it under the terms of the GNU General Public License as published by
10
// the Free Software Foundation; either version 2 of the License, or
11
// (at your option) any later version.
12
//
13
// This program is distributed in the hope that it will be useful,
14
// but WITHOUT ANY WARRANTY; without even the implied warranty of
15
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
// GNU General Public License for more details.
17
//
18
// You should have received a copy of the GNU General Public License
19
// along with this program; if not, write to the Free Software
20
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21
//
22
// This product is not authorized for use as critical component in 
23
// life support systems without the express written approval of 
24
// ARW Elektronik Germany.
25
//  
26
// Please announce changes and hints to ARW Elektronik
27
//
28
// Maintainer(s): Klaus Hitschler (klaus.hitschler@gmx.de)
29
//
30
//****************************************************************************
31
 
32
//****************************************************************************
33
//
34
// list.h - Header file for list.c
35
//
36
// $Log: list.h,v $
37
// Revision 1.5  2004/08/12 19:59:19  klaus
38
// conversion to kernel-version 2.6, released version 6.0
39
//
40
// Revision 1.4  2002/04/10 18:40:10  klaus
41
// compiled and modified on RedHat 7.2
42
//
43
// Revision 1.3  2001/11/20 20:12:50  klaus
44
// included new header and CVS log
45
//
46
//
47
// derived from code original by Dirk Muehlenberg               AR   18.02.2000
48
// removed all ANEW, FREE because of MODVERSIONS                AR   24.04.2000
49
//
50
//****************************************************************************
51
 
52
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)
53
#include <linux/malloc.h>
54
#else
55
#include <linux/slab.h>
56
#endif
57
 
58
typedef struct _node
59
{
60
  struct _node *pred;  /* points to previous      */
61
  struct _node *succ;  /* points to next          */
62
  void *data;          /* points to work load     */
63
} Node;
64
 
65
typedef struct  _list
66
{
67
  Node *head;          /* points to head of list  */
68
  Node *tail;          /* points to tail of list  */
69
  int nodes;           /* current number of nodes */
70
} List;
71
 
72
enum NodePosition {CurrentLeft, CurrentRight};
73
 
74
/*-- PROTOTYPES ----------------------------------------------------------------------*/
75
Node *initNode(void);
76
Node *addNode(Node *, void *, enum NodePosition);
77
Node *delNode(Node *);
78
 
79
List *newList(void);
80
void deleteList(List *, void (*)(void *));
81
Node *addTail(List *, void *);
82
Node *addHead(List *, void *);
83
Node *searchList(List *, void *, int (*)(void *, void *));
84
void delNodeInList(List *, Node *);
85
void delNodeAndDataInList(List *, Node *);
86
void delTail(List *);
87
void delTailAndData(List *);
88
void resetList(List *, void (*)(void *));
89
void printList(List *, char *(*)(void *));
90
#ifndef USE_MACROS
91
int getNumOfNodesInList(List *);
92
#else
93
#define getNumOfNodesInList(l) l->nodes
94
#endif
95
int emptyList(List *);
96
/* for lifo-, fifo operations */
97
Node *getFirstNode(List *);
98
Node *getNextNode(Node *);
99
Node *getPrevNode(Node *);
100
Node *getLastNode(List *);
101
void *getContent(Node *n);
102
void delFirstNode(List *);
103
void delFirstNodeAndData(List *);
104
void delLastNode(List *);
105
void delLastNodeAndData(List *);
106
 
107
#endif /* __LIST_H__ */
108