diff options
Diffstat (limited to 'apps/plugins/mpegplayer/mpeg_linkedlist.c')
-rw-r--r-- | apps/plugins/mpegplayer/mpeg_linkedlist.c | 151 |
1 files changed, 0 insertions, 151 deletions
diff --git a/apps/plugins/mpegplayer/mpeg_linkedlist.c b/apps/plugins/mpegplayer/mpeg_linkedlist.c deleted file mode 100644 index f2d01ee493..0000000000 --- a/apps/plugins/mpegplayer/mpeg_linkedlist.c +++ /dev/null | |||
@@ -1,151 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Linked list API definitions | ||
11 | * | ||
12 | * Copyright (c) 2007 Michael Sevakis | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or | ||
15 | * modify it under the terms of the GNU General Public License | ||
16 | * as published by the Free Software Foundation; either version 2 | ||
17 | * of the License, or (at your option) any later version. | ||
18 | * | ||
19 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
20 | * KIND, either express or implied. | ||
21 | * | ||
22 | ****************************************************************************/ | ||
23 | #include "plugin.h" | ||
24 | #include "mpegplayer.h" | ||
25 | #include "mpeg_linkedlist.h" | ||
26 | |||
27 | /* Initialize a master list head */ | ||
28 | void list_initialize(struct list_item *master_list_head) | ||
29 | { | ||
30 | master_list_head->prev = master_list_head->next = NULL; | ||
31 | } | ||
32 | |||
33 | /* Are there items after the head item? */ | ||
34 | bool list_is_empty(struct list_item *head_item) | ||
35 | { | ||
36 | return head_item->next == NULL; | ||
37 | } | ||
38 | |||
39 | /* Does the item belong to a list? */ | ||
40 | bool list_is_item_listed(struct list_item *item) | ||
41 | { | ||
42 | return item->prev != NULL; | ||
43 | } | ||
44 | |||
45 | /* Is the item a member in a particular list? */ | ||
46 | bool list_is_member(struct list_item *master_list_head, | ||
47 | struct list_item *item) | ||
48 | { | ||
49 | if (item != master_list_head && item->prev != NULL) | ||
50 | { | ||
51 | struct list_item *curr = master_list_head->next; | ||
52 | |||
53 | while (curr != NULL) | ||
54 | { | ||
55 | if (item != curr) | ||
56 | { | ||
57 | curr = curr->next; | ||
58 | continue; | ||
59 | } | ||
60 | |||
61 | return true; | ||
62 | } | ||
63 | } | ||
64 | |||
65 | return false; | ||
66 | } | ||
67 | |||
68 | /* Remove an item from a list - no head item needed */ | ||
69 | void list_remove_item(struct list_item *item) | ||
70 | { | ||
71 | if (item->prev == NULL) | ||
72 | { | ||
73 | /* Not in a list - no change - could be the master list head | ||
74 | * as well which cannot be removed */ | ||
75 | return; | ||
76 | } | ||
77 | |||
78 | item->prev->next = item->next; | ||
79 | |||
80 | if (item->next != NULL) | ||
81 | { | ||
82 | /* Not last item */ | ||
83 | item->next->prev = item->prev; | ||
84 | } | ||
85 | |||
86 | /* Mark as not in a list */ | ||
87 | item->prev = NULL; | ||
88 | } | ||
89 | |||
90 | /* Add a list item after the base item */ | ||
91 | void list_add_item(struct list_item *head_item, | ||
92 | struct list_item *item) | ||
93 | { | ||
94 | if (item->prev != NULL) | ||
95 | { | ||
96 | /* Already in a list - no change */ | ||
97 | DEBUGF("list_add_item: item already in a list\n"); | ||
98 | return; | ||
99 | } | ||
100 | |||
101 | if (item == head_item) | ||
102 | { | ||
103 | /* Cannot add the item to itself */ | ||
104 | DEBUGF("list_add_item: item == head_item\n"); | ||
105 | return; | ||
106 | } | ||
107 | |||
108 | /* Insert first */ | ||
109 | item->prev = head_item; | ||
110 | item->next = head_item->next; | ||
111 | |||
112 | if (head_item->next != NULL) | ||
113 | { | ||
114 | /* Not first item */ | ||
115 | head_item->next->prev = item; | ||
116 | } | ||
117 | |||
118 | head_item->next = item; | ||
119 | } | ||
120 | |||
121 | /* Clear list items after the head item */ | ||
122 | void list_clear_all(struct list_item *head_item) | ||
123 | { | ||
124 | struct list_item *curr = head_item->next; | ||
125 | |||
126 | while (curr != NULL) | ||
127 | { | ||
128 | list_remove_item(curr); | ||
129 | curr = head_item->next; | ||
130 | } | ||
131 | } | ||
132 | |||
133 | /* Enumerate all items after the head item - passing each item in turn | ||
134 | * to the callback as well as the data value. The current item may be | ||
135 | * safely removed. Items added after the current position will be enumated | ||
136 | * but not ones added before it. The callback may return false to stop | ||
137 | * the enumeration. */ | ||
138 | void list_enum_items(struct list_item *head_item, | ||
139 | list_enum_callback_t callback, | ||
140 | intptr_t data) | ||
141 | { | ||
142 | struct list_item *next = head_item->next; | ||
143 | |||
144 | while (next != NULL) | ||
145 | { | ||
146 | struct list_item *curr = next; | ||
147 | next = curr->next; | ||
148 | if (!callback(curr, data)) | ||
149 | break; | ||
150 | } | ||
151 | } | ||