1 | /*
|
---|
2 | cl_list.c
|
---|
3 | Definition of a linked list of card-terminals
|
---|
4 |
|
---|
5 | This file is part of the Unix driver for Towitoko smartcard readers
|
---|
6 | Copyright (C) 2000 Carlos Prados <cprados@yahoo.com>
|
---|
7 |
|
---|
8 | This version is modified by doz21 to work in a special manner ;)
|
---|
9 |
|
---|
10 | This library is free software; you can redistribute it and/or
|
---|
11 | modify it under the terms of the GNU Lesser General Public
|
---|
12 | License as published by the Free Software Foundation; either
|
---|
13 | version 2 of the License, or (at your option) any later version.
|
---|
14 |
|
---|
15 | This library is distributed in the hope that it will be useful,
|
---|
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
18 | Lesser General Public License for more details.
|
---|
19 |
|
---|
20 | You should have received a copy of the GNU Lesser General Public
|
---|
21 | License along with this library; if not, write to the Free Software
|
---|
22 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
23 | */
|
---|
24 |
|
---|
25 | #ifndef _CT_LIST_
|
---|
26 | #define _CT_LIST_
|
---|
27 |
|
---|
28 | #include "defines.h"
|
---|
29 | #include "cardterminal.h"
|
---|
30 |
|
---|
31 | /*
|
---|
32 | * Exported datatypes definition
|
---|
33 | */
|
---|
34 |
|
---|
35 | /* Node of the list */
|
---|
36 | struct CT_List_Node
|
---|
37 | {
|
---|
38 | unsigned short ctn; /* Card Terminal number */
|
---|
39 | CardTerminal *ct; /* Card Terminal reference */
|
---|
40 | struct CT_List_Node *next; /* Next node of the list */
|
---|
41 | };
|
---|
42 |
|
---|
43 | /* Linked list of card-terminals */
|
---|
44 | typedef struct
|
---|
45 | {
|
---|
46 | struct CT_List_Node *first; /* First element */
|
---|
47 | struct CT_List_Node *last; /* Last element */
|
---|
48 | int elements; /* Number of elements */
|
---|
49 | }
|
---|
50 | CT_List;
|
---|
51 |
|
---|
52 | /*
|
---|
53 | * Exported functions declaration
|
---|
54 | */
|
---|
55 |
|
---|
56 | /* Creates a new list of CardTerminals */
|
---|
57 | extern CT_List *
|
---|
58 | CT_List_New (void);
|
---|
59 |
|
---|
60 | /* Adds a CardTerminal to a existing list */
|
---|
61 | extern bool
|
---|
62 | CT_List_AddCardTerminal (CT_List * list, CardTerminal * ct, unsigned short ctn);
|
---|
63 |
|
---|
64 | /* Returns a CardTerminal by its number or NULL if not found */
|
---|
65 | extern CardTerminal *
|
---|
66 | CT_List_GetCardTerminal (CT_List * list, unsigned short ctn);
|
---|
67 |
|
---|
68 | /* Returns the number of CardTerminals in a list */
|
---|
69 | extern int
|
---|
70 | CT_List_GetNumberOfElements (CT_List * list);
|
---|
71 |
|
---|
72 | /* Removes a CardTerminal from a list by its number */
|
---|
73 | extern bool
|
---|
74 | CT_List_RemoveCardTerminal (CT_List * list, unsigned short ctn);
|
---|
75 |
|
---|
76 | /* Empties and removes a list */
|
---|
77 | extern void
|
---|
78 | CT_List_Delete (CT_List * list);
|
---|
79 |
|
---|
80 | #endif /* _CT_LIST_ */
|
---|
81 |
|
---|