~medibuntu-maintainers/mplayer/medibuntu.precise

« back to all changes in this revision

Viewing changes to gui/util/list.c

  • Committer: Gauvain Pocentek
  • Date: 2012-03-06 11:59:12 UTC
  • mfrom: (66.1.15 precise)
  • Revision ID: gauvain@pocentek.net-20120306115912-h9d6kt9j0l532oo5
* Merge from Ubuntu:
  - put back faac support
  - recommends apport-hooks-medibuntu
  - change Maintainer, Uploaders & Vcs-* fields.
* New upstream snapshot
* upload to unstable
* Build against external libmpeg2
* drop 51_FTBFS_arm.patch again
* no longer build depend on libcdparanoia-dev on the Hurd
* Fix FTBFS on the hurd.
  Thanks to Samuel Thibault <sthibault@debian.org> (Closes: #654974)
* Fix FTBFS on arm
* New upstream snapshot, Closes: #650339, #643621, #481807
* Imported Upstream version 1.0~rc4+svn34492
* Bump standards version
* Bump dependency on libav >= 4:0.8~, Closes: #653887
* Fix build-indep
* Build mplayer-gui again, Closes: #568514
* Drop debian/all-lang-config-mak.sh, no longer needed
* include .dfsg1 in version number
* remove get-orig-source target
* no longer prune compiler flags from the environment
* No longer advertise nor build 3fdx, mga and dxr3 backends,
  Closes: #496106, #442181, #533546
* beautify mplayer version identification string
* Brown paperbag upload.
* Next try to fix build failure on sparce after recent binutils change.
* Brown paperbag upload.
* Really fix build failure on sparc after recent binutils change.
* Properly set Replaces/Conflicts on mplayer2{,-dbg} to avoid
  file overwrite errors.
* Adjust versioning of mplayer listed in the mplayer-dbg's Depends field.
* Fix build failure on sparc after recent binutils change.
* Urgency medium bumped because of RC-level bugfix
  and speeding up x264 transition.
* Update to my @debian.org email.
* Upload to unstable
* Enable joystick support on Linux only, Closes: #638408
* Rebuild fixes toolchain issue on arm, Closes: #637077
* New upstream snapshot
* following the discussion started by Diego Biurrun <diego@biurrun.de>
  in debian-devel, I have prepared a new packaging of 'mplayer'
  (with code that comes from CVS)
* the upstream tar.bz cannot be distributed by Debian, since it contains
   CSS code; so I am repackaging it 
* I have tried my best to address all known issues:
  - the package contains the detailed Copyright made by Diego Biurrun 
  - the package does not contain CSS code, or  AFAIK other code on which 
     there is active patent enforcement
  - there is a script  debian/cvs-changelog.sh  that shows all changes
     done to files included in this source.
    This should comply with GPLv2 sec 2.a  (in spirit if not in letter)
    For this reason, the source code contains CVS directories.
* needs   make (>= 3.80) for 'html-chunked-$(1)' in DOCS/xml/Makefile

* some corrections, as suggested Diego Biurrun
  - binary codecs should go into /usr/lib/codecs (upstream default)
  - better template 'mplayer/install_codecs'
  - an empty 'font=' in mplayer.conf breaks mplayer: postinst corrected
* correction in 'mplayer/cfgnote'
* better mplayer.postinst and mplayer.config

* New upstream release
* better debian/copyright file
* do not ship a skin
* New upstream release
* changed DEB_BUILD_OPTIONS to DEB_BUILD_CONFIGURE ,
  DEB_BUILD_OPTIONS is used as in debian policy
* use gcc-3.4
* changed xlibs-dev to a long list of dependencies, for Debian/etch
* try to adhere to  http://www.mplayerhq.hu/DOCS/tech/binary-packaging.txt
  (see README.Debian for details)
* removed dependency on xlibmesa-dev, disabled opengl
* New upstream release
* Simon McVittie <hacks@pseudorandom.co.uk> wonderful work:
- Work around Debian bug #267442 (glibc's sys/uio.h and gcc's altivec.h have
  conflicting uses for __vector) by re-ordering #includes
- Fix potential symlink attack in ./configure
- Disable support for binary codecs on platforms for which those codecs
  aren't available; also disable the corresponding Debconf note when it's
  inappropriate
- Changed Build-Depends: so it works in pbuilder
- Explicitly build-depend on libjpeg62-dev, libfontconfig1-dev,
  libungif4-dev 
- Tweak debian/rules to avoid certain errors being ignored
- Use --language=all
* provide a target  'debian/rules get-orig-source' 
  that recreates the orig.tar.gz ; then use the above orig.tar.gz
* rewrote some parts of debian/rules
* don't clean and recompile docs if upstream ships them
* mplayer-doc was shipping too much stuff
* translated man pages where not installed properly
* compile with libdv4-dev
* correct README.Debian
* Forgot build-dep on libtheora
* Must not depend on libxvidcore
* New upstream release
* new release.
* rc1 to become 0.90
* new pre-release
* new pre-release
* gtk bug fixed.
* new release.
* version bumped
* 0.60 pre2 release
* 0.60 pre-release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This file is part of MPlayer.
 
3
 *
 
4
 * MPlayer is free software; you can redistribute it and/or modify
 
5
 * it under the terms of the GNU General Public License as published by
 
6
 * the Free Software Foundation; either version 2 of the License, or
 
7
 * (at your option) any later version.
 
8
 *
 
9
 * MPlayer 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 along
 
15
 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
 
16
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
17
 */
 
18
 
 
19
#include <stdlib.h>
 
20
#include <string.h>
 
21
 
 
22
#include "list.h"
 
23
#include "string.h"
 
24
 
 
25
plItem *plList;
 
26
plItem *plCurrent;
 
27
plItem *plLastPlayed;
 
28
 
 
29
urlItem *urlList;
 
30
 
 
31
void *listSet(int cmd, void *vparam)
 
32
{
 
33
    plItem *item      = (plItem *)vparam;
 
34
    urlItem *url_item = (urlItem *)vparam;
 
35
    int is_added      = 1;
 
36
 
 
37
    switch (cmd) {
 
38
    // handle playlist
 
39
 
 
40
    // add item to playlist
 
41
    case gtkAddPlItem:
 
42
        if (plList) {
 
43
            plItem *next = plList;
 
44
 
 
45
            while (next->next)
 
46
// {
 
47
// printf( "%s\n",next->name );
 
48
                next = next->next;
 
49
// }
 
50
 
 
51
            next->next = item;
 
52
            item->prev = next;
 
53
            item->next = NULL;
 
54
        } else {
 
55
            item->prev = item->next = NULL;
 
56
            plCurrent  = plList = item;
 
57
        }
 
58
        return NULL;
 
59
 
 
60
    // add item into playlist after current
 
61
    case gtkInsertPlItem:
 
62
        if (plCurrent) {
 
63
            plItem *curr = plCurrent;
 
64
            item->next = curr->next;
 
65
 
 
66
            if (item->next)
 
67
                item->next->prev = item;
 
68
 
 
69
            item->prev = curr;
 
70
            curr->next = item;
 
71
            plCurrent  = plCurrent->next;
 
72
 
 
73
            return plCurrent;
 
74
        } else
 
75
            return listSet(gtkAddPlItem, item);
 
76
 
 
77
    // get next item from playlist
 
78
    case gtkGetNextPlItem:
 
79
        if (plCurrent && plCurrent->next) {
 
80
            plCurrent = plCurrent->next;
 
81
// if (!plCurrent && plList)
 
82
// {
 
83
// plItem *next = plList;
 
84
//
 
85
// while (next->next)
 
86
// {
 
87
// if (!next->next) break;
 
88
// next = next->next;
 
89
// }
 
90
//
 
91
// plCurrent = next;
 
92
// }
 
93
            return plCurrent;
 
94
        }
 
95
        return NULL;
 
96
 
 
97
    // get previous item from playlist
 
98
    case gtkGetPrevPlItem:
 
99
        if (plCurrent && plCurrent->prev) {
 
100
            plCurrent = plCurrent->prev;
 
101
// if ( !plCurrent && plList ) plCurrent=plList;
 
102
            return plCurrent;
 
103
        }
 
104
        return NULL;
 
105
 
 
106
    // set current item
 
107
    case gtkSetCurrPlItem:
 
108
        plCurrent = item;
 
109
        return plCurrent;
 
110
 
 
111
    // get current item
 
112
    case gtkGetCurrPlItem:
 
113
        return plCurrent;
 
114
 
 
115
    // delete current item
 
116
    case gtkDelCurrPlItem:
 
117
    {
 
118
        plItem *curr = plCurrent;
 
119
 
 
120
        if (!curr)
 
121
            return NULL;
 
122
 
 
123
        if (curr->prev)
 
124
            curr->prev->next = curr->next;
 
125
        if (curr->next)
 
126
            curr->next->prev = curr->prev;
 
127
        if (curr == plList)
 
128
            plList = curr->next;
 
129
 
 
130
        plCurrent = curr->next;
 
131
 
 
132
        // free it
 
133
        free(curr->path);
 
134
        free(curr->name);
 
135
        free(curr);
 
136
    }
 
137
        //uiCurr();     // instead of using uiNext && uiPrev
 
138
        return plCurrent;
 
139
 
 
140
    // delete list
 
141
    case gtkDelPl:
 
142
    {
 
143
        plItem *curr = plList;
 
144
        plItem *next;
 
145
 
 
146
        if (!plList)
 
147
            return NULL;
 
148
 
 
149
        if (!curr->next) {
 
150
            free(curr->path);
 
151
            free(curr->name);
 
152
            free(curr);
 
153
        } else {
 
154
            while (curr->next) {
 
155
                next = curr->next;
 
156
                free(curr->path);
 
157
                free(curr->name);
 
158
                free(curr);
 
159
                curr = next;
 
160
            }
 
161
        }
 
162
 
 
163
        plList    = NULL;
 
164
        plCurrent = NULL;
 
165
    }
 
166
        return NULL;
 
167
 
 
168
    // handle url
 
169
    case gtkAddURLItem:
 
170
        if (urlList) {
 
171
            urlItem *next_url = urlList;
 
172
            is_added = 0;
 
173
 
 
174
            while (next_url->next) {
 
175
                if (!gstrcmp(next_url->url, url_item->url)) {
 
176
                    is_added = 1;
 
177
                    break;
 
178
                }
 
179
 
 
180
                next_url = next_url->next;
 
181
            }
 
182
 
 
183
            if (!is_added && gstrcmp(next_url->url, url_item->url))
 
184
                next_url->next = url_item;
 
185
        } else {
 
186
            url_item->next = NULL;
 
187
            urlList = url_item;
 
188
        }
 
189
        return NULL;
 
190
    }
 
191
 
 
192
    return NULL;
 
193
}
 
194
 
 
195
/**
 
196
 * \brief This actually creates a new list containing only one element...
 
197
 */
 
198
void gaddlist(char ***list, const char *entry)
 
199
{
 
200
    int i;
 
201
 
 
202
    if (*list) {
 
203
        for (i = 0; (*list)[i]; i++)
 
204
            free((*list)[i]);
 
205
 
 
206
        free(*list);
 
207
    }
 
208
 
 
209
    *list      = malloc(2 * sizeof(char **));
 
210
    (*list)[0] = gstrdup(entry);
 
211
    (*list)[1] = NULL;
 
212
}
 
213
 
 
214
/**
 
215
 * \brief This replaces a string starting with search by replace.
 
216
 * If not found, replace is appended.
 
217
 */
 
218
void greplace(char ***list, const char *search, const char *replace)
 
219
{
 
220
    int i   = 0;
 
221
    int len = (search ? strlen(search) : 0);
 
222
 
 
223
    if (*list) {
 
224
        for (i = 0; (*list)[i]; i++) {
 
225
            if (search && (strncmp((*list)[i], search, len) == 0)) {
 
226
                free((*list)[i]);
 
227
                (*list)[i] = gstrdup(replace);
 
228
                return;
 
229
            }
 
230
        }
 
231
 
 
232
        *list = realloc(*list, (i + 2) * sizeof(char *));
 
233
    } else
 
234
        *list = malloc(2 * sizeof(char *));
 
235
 
 
236
    (*list)[i]     = gstrdup(replace);
 
237
    (*list)[i + 1] = NULL;
 
238
}