/[LeafOK_CVS]/pvpgn-1.7.4/src/common/list.h
ViewVC logotype

Annotation of /pvpgn-1.7.4/src/common/list.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (hide annotations) (vendor branch)
Tue Jun 6 03:41:38 2006 UTC (19 years, 9 months ago) by sysadm
Branch: GNU, MAIN
CVS Tags: arelease, HEAD
Changes since 1.1: +0 -0 lines
Content type: text/x-chdr
no message

1 sysadm 1.1 /*
2     * Copyright (C) 1999,2000 Ross Combs (rocombs@cs.nmsu.edu)
3     *
4     * This program is free software; you can redistribute it and/or
5     * modify it under the terms of the GNU General Public License
6     * as published by the Free Software Foundation; either version 2
7     * of the License, or (at your option) any later version.
8     *
9     * This program is distributed in the hope that it will be useful,
10     * but WITHOUT ANY WARRANTY; without even the implied warranty of
11     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12     * GNU General Public License for more details.
13     *
14     * You should have received a copy of the GNU General Public License
15     * along with this program; if not, write to the Free Software
16     * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17     */
18     #ifndef INCLUDED_LIST_TYPES
19     #define INCLUDED_LIST_TYPES
20    
21     typedef struct elem
22     #ifdef LIST_INTERNAL_ACCESS
23     {
24     void * data;
25     struct elem * prev;
26     struct elem * next;
27     }
28     #endif
29     t_elem;
30    
31     typedef struct list
32     #ifdef LIST_INTERNAL_ACCESS
33     {
34     unsigned int len;
35     t_elem * head;
36     t_elem * tail;
37     }
38     #endif
39     t_list;
40    
41     #endif
42    
43    
44     /*****/
45     #ifndef JUST_NEED_TYPES
46     #ifndef INCLUDED_LIST_PROTOS
47     #define INCLUDED_LIST_PROTOS
48    
49     extern t_list * list_create(void) ;
50     extern int list_destroy(t_list * list);
51     extern unsigned int list_get_length(t_list const * list);
52     extern int list_prepend_data(t_list * list, void * data);
53     extern int list_append_data(t_list * list, void * data);
54     extern t_elem * list_get_elem_by_data(t_list const * list, void const * data);
55     extern t_elem const * list_get_elem_by_data_const(t_list const * list, void const * data);
56    
57     /* note changed API for those commands:
58     due to direct removal of elements from list, you need to take special care during list traversal.
59     a pointer to the traversal variable needs to be passed to the list_remove functions, so they
60     can properly modify it to point to the "previous" element (the one before the element to be deleted)
61     so the next elem_get_next call will address the "next" element (the one after the element to be deleted) */
62    
63     extern int list_remove_data(t_list * list, void const * data, t_elem ** elem); /* delete matching item */
64     extern int list_remove_elem(t_list * list, t_elem ** elem);
65    
66     extern void * list_get_data_by_pos(t_list const * list, unsigned int pos);
67     #ifdef LIST_DEBUG
68     extern t_elem * list_get_first_real(t_list const * list, char const * fn, unsigned int ln);
69     # define list_get_first(L) list_get_first_real(L,__FILE__,__LINE__)
70     #else
71     extern t_elem * list_get_first(t_list const * list);
72     #endif
73     #ifdef LIST_DEBUG
74     extern t_elem const * list_get_first_const_real(t_list const * list, char const * fn, unsigned int ln);
75     # define list_get_first_const(L) list_get_first_const_real(L,__FILE__,__LINE__)
76     #else
77     extern t_elem const * list_get_first_const(t_list const * list);
78     #endif
79    
80     extern void * elem_get_data(t_elem const * elem);
81     extern int elem_set_data(t_elem * elem, void * data);
82     #define elem_get_next(list,elem) elem_get_next_real(list,elem,__FILE__,__LINE__)
83     extern t_elem * elem_get_next_real(t_list const * list, t_elem const * elem,char const * fn, unsigned int ln);
84     extern t_elem const * elem_get_next_const(t_list const * list, t_elem const * elem);
85    
86     #define LIST_TRAVERSE(list,curr) for (curr=(list)?list_get_first(list):(NULL); curr; curr=elem_get_next(list,curr))
87     #define LIST_TRAVERSE_CONST(list,curr) for (curr=(list)?list_get_first_const(list):(NULL); curr; curr=elem_get_next_const(list,curr))
88    
89     #endif
90     #endif

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1