annotate gui/util/list.c @ 34040:02ffd25c7733

configure: drop extra standard compiler/linker flags for *BSD systems Adding the standard library locations to the search path is doubtful behavior and unnecessary at least on FreeBSD.
author diego
date Fri, 23 Sep 2011 16:08:15 +0000
parents 5860cfaff0a4
children 80246b016caf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
33741
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
1 /*
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
2 * This file is part of MPlayer.
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
3 *
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
4 * MPlayer is free software; you can redistribute it and/or modify
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
7 * (at your option) any later version.
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
8 *
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
9 * MPlayer is distributed in the hope that it will be useful,
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
12 * GNU General Public License for more details.
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
13 *
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
14 * You should have received a copy of the GNU General Public License along
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
17 */
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
18
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
19 #include <stdlib.h>
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
20 #include <string.h>
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
21
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
22 #include "list.h"
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
23 #include "string.h"
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
24
33742
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
25 plItem *plList;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
26 plItem *plCurrent;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
27 plItem *plLastPlayed;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
28
33748
5860cfaff0a4 Cosmetic: Rename URLList urlList.
ib
parents: 33742
diff changeset
29 urlItem *urlList;
33742
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
30
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
31 void *listSet(int cmd, void *vparam)
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
32 {
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
33 plItem *item = (plItem *)vparam;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
34 urlItem *url_item = (urlItem *)vparam;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
35 int is_added = 1;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
36
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
37 switch (cmd) {
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
38 // handle playlist
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
39
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
40 // add item to playlist
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
41 case gtkAddPlItem:
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
42 if (plList) {
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
43 plItem *next = plList;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
44
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
45 while (next->next)
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
46 // {
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
47 // printf( "%s\n",next->name );
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
48 next = next->next;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
49 // }
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
50
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
51 next->next = item;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
52 item->prev = next;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
53 item->next = NULL;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
54 } else {
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
55 item->prev = item->next = NULL;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
56 plCurrent = plList = item;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
57 }
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
58 return NULL;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
59
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
60 // add item into playlist after current
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
61 case gtkInsertPlItem:
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
62 if (plCurrent) {
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
63 plItem *curr = plCurrent;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
64 item->next = curr->next;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
65
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
66 if (item->next)
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
67 item->next->prev = item;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
68
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
69 item->prev = curr;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
70 curr->next = item;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
71 plCurrent = plCurrent->next;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
72
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
73 return plCurrent;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
74 } else
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
75 return listSet(gtkAddPlItem, item);
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
76
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
77 // get next item from playlist
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
78 case gtkGetNextPlItem:
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
79 if (plCurrent && plCurrent->next) {
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
80 plCurrent = plCurrent->next;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
81 // if (!plCurrent && plList)
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
82 // {
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
83 // plItem *next = plList;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
84 //
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
85 // while (next->next)
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
86 // {
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
87 // if (!next->next) break;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
88 // next = next->next;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
89 // }
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
90 //
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
91 // plCurrent = next;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
92 // }
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
93 return plCurrent;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
94 }
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
95 return NULL;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
96
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
97 // get previous item from playlist
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
98 case gtkGetPrevPlItem:
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
99 if (plCurrent && plCurrent->prev) {
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
100 plCurrent = plCurrent->prev;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
101 // if ( !plCurrent && plList ) plCurrent=plList;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
102 return plCurrent;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
103 }
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
104 return NULL;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
105
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
106 // set current item
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
107 case gtkSetCurrPlItem:
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
108 plCurrent = item;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
109 return plCurrent;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
110
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
111 // get current item
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
112 case gtkGetCurrPlItem:
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
113 return plCurrent;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
114
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
115 // delete current item
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
116 case gtkDelCurrPlItem:
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
117 {
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
118 plItem *curr = plCurrent;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
119
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
120 if (!curr)
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
121 return NULL;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
122
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
123 if (curr->prev)
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
124 curr->prev->next = curr->next;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
125 if (curr->next)
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
126 curr->next->prev = curr->prev;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
127 if (curr == plList)
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
128 plList = curr->next;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
129
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
130 plCurrent = curr->next;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
131
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
132 // free it
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
133 free(curr->path);
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
134 free(curr->name);
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
135 free(curr);
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
136 }
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
137 //uiCurr(); // instead of using uiNext && uiPrev
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
138 return plCurrent;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
139
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
140 // delete list
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
141 case gtkDelPl:
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
142 {
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
143 plItem *curr = plList;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
144 plItem *next;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
145
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
146 if (!plList)
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
147 return NULL;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
148
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
149 if (!curr->next) {
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
150 free(curr->path);
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
151 free(curr->name);
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
152 free(curr);
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
153 } else {
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
154 while (curr->next) {
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
155 next = curr->next;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
156 free(curr->path);
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
157 free(curr->name);
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
158 free(curr);
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
159 curr = next;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
160 }
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
161 }
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
162
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
163 plList = NULL;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
164 plCurrent = NULL;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
165 }
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
166 return NULL;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
167
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
168 // handle url
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
169 case gtkAddURLItem:
33748
5860cfaff0a4 Cosmetic: Rename URLList urlList.
ib
parents: 33742
diff changeset
170 if (urlList) {
5860cfaff0a4 Cosmetic: Rename URLList urlList.
ib
parents: 33742
diff changeset
171 urlItem *next_url = urlList;
33742
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
172 is_added = 0;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
173
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
174 while (next_url->next) {
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
175 if (!gstrcmp(next_url->url, url_item->url)) {
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
176 is_added = 1;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
177 break;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
178 }
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
179
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
180 next_url = next_url->next;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
181 }
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
182
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
183 if (!is_added && gstrcmp(next_url->url, url_item->url))
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
184 next_url->next = url_item;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
185 } else {
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
186 url_item->next = NULL;
33748
5860cfaff0a4 Cosmetic: Rename URLList urlList.
ib
parents: 33742
diff changeset
187 urlList = url_item;
33742
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
188 }
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
189 return NULL;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
190 }
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
191
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
192 return NULL;
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
193 }
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33741
diff changeset
194
33741
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
195 /**
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
196 * \brief This actually creates a new list containing only one element...
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
197 */
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
198 void gaddlist(char ***list, const char *entry)
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
199 {
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
200 int i;
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
201
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
202 if (*list) {
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
203 for (i = 0; (*list)[i]; i++)
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
204 free((*list)[i]);
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
205
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
206 free(*list);
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
207 }
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
208
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
209 *list = malloc(2 * sizeof(char **));
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
210 (*list)[0] = gstrdup(entry);
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
211 (*list)[1] = NULL;
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
212 }
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
213
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
214 /**
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
215 * \brief This replaces a string starting with search by replace.
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
216 * If not found, replace is appended.
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
217 */
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
218 void greplace(char ***list, const char *search, const char *replace)
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
219 {
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
220 int i = 0;
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
221 int len = (search ? strlen(search) : 0);
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
222
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
223 if (*list) {
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
224 for (i = 0; (*list)[i]; i++) {
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
225 if (search && (strncmp((*list)[i], search, len) == 0)) {
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
226 free((*list)[i]);
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
227 (*list)[i] = gstrdup(replace);
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
228 return;
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
229 }
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
230 }
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
231
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
232 *list = realloc(*list, (i + 2) * sizeof(char *));
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
233 } else
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
234 *list = malloc(2 * sizeof(char *));
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
235
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
236 (*list)[i] = gstrdup(replace);
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
237 (*list)[i + 1] = NULL;
962dc701989d Create new file list.c for list related functions.
ib
parents:
diff changeset
238 }