]> git.sesse.net Git - vlc/blob - modules/video_filter/rss.c
* Introduced a new text_style_t
[vlc] / modules / video_filter / rss.c
1 /*****************************************************************************
2  * rss.c : rss feed display video plugin for vlc
3  *****************************************************************************
4  * Copyright (C) 2003-2005 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Antoine Cellerier <dionoea@videolan.org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 /*****************************************************************************
25  * Preamble
26  *****************************************************************************/
27 #include <stdlib.h>                                      /* malloc(), free() */
28 #include <string.h>
29
30 #include <vlc/vlc.h>
31 #include <vlc/vout.h>
32
33 #include "vlc_filter.h"
34 #include "vlc_block.h"
35 #include "vlc_osd.h"
36
37 #include "vlc_block.h"
38 #include "vlc_stream.h"
39 #include "vlc_xml.h"
40
41 /*****************************************************************************
42  * Local prototypes
43  *****************************************************************************/
44 static int  CreateFilter ( vlc_object_t * );
45 static void DestroyFilter( vlc_object_t * );
46 static subpicture_t *Filter( filter_t *, mtime_t );
47
48 static int FetchRSS( filter_t * );
49 static void FreeRSS( filter_t * );
50
51 static int pi_color_values[] = { 0xf0000000, 0x00000000, 0x00808080, 0x00C0C0C0,
52                0x00FFFFFF, 0x00800000, 0x00FF0000, 0x00FF00FF, 0x00FFFF00,
53                0x00808000, 0x00008000, 0x00008080, 0x0000FF00, 0x00800080,
54                0x00000080, 0x000000FF, 0x0000FFFF};
55 static char *ppsz_color_descriptions[] = { N_("Default"), N_("Black"),
56                N_("Gray"), N_("Silver"), N_("White"), N_("Maroon"), N_("Red"),
57                N_("Fuchsia"), N_("Yellow"), N_("Olive"), N_("Green"),
58                N_("Teal"), N_("Lime"), N_("Purple"), N_("Navy"), N_("Blue"),
59                N_("Aqua") };
60
61 /*****************************************************************************
62  * filter_sys_t: rss filter descriptor
63  *****************************************************************************/
64
65 struct rss_item_t
66 {
67     char *psz_title;
68     char *psz_description;
69     char *psz_link;
70 };
71
72 struct rss_feed_t
73 {
74     char *psz_title;
75     char *psz_description;
76     char *psz_link;
77
78     int i_items;
79     struct rss_item_t *p_items;
80 };
81
82 struct filter_sys_t
83 {
84     vlc_mutex_t lock;
85     vlc_mutex_t *p_lock;
86
87     int i_xoff, i_yoff;  /* offsets for the display string in the video window */
88     int i_pos; /* permit relative positioning (top, bottom, left, right, center) */
89     int i_speed;
90     int i_length;
91
92     char *psz_marquee;    /* marquee string */
93
94     text_style_t *p_style; /* font control */
95
96     mtime_t last_date;
97
98     char *psz_urls;
99     int i_feeds;
100     struct rss_feed_t *p_feeds;
101
102     int i_ttl;
103     time_t t_last_update;
104
105     int i_cur_feed;
106     int i_cur_item;
107     int i_cur_char;
108 };
109
110 #define MSG_TEXT N_("RSS feed URLs")
111 #define MSG_LONGTEXT N_("RSS feed '|' (pipe) seperated URLs")
112 #define SPEED_TEXT N_("RSS feed speed")
113 #define SPEED_LONGTEXT N_("RSS feed speed (bigger is slower)")
114 #define LENGTH_TEXT N_("RSS feed max number of chars displayed")
115 #define LENGTH_LONGTEXT N_("RSS feed max number of chars displayed")
116 #define TTL_TEXT N_("Number of seconds between each forced refresh of the feeds")
117 #define TTL_LONGTEXT N_("Number of seconds between each forced refresh of the feeds. If 0, the feeds will never be updated.")
118
119
120 #define POSX_TEXT N_("X offset, from left")
121 #define POSX_LONGTEXT N_("X offset, from the left screen edge" )
122 #define POSY_TEXT N_("Y offset, from the top")
123 #define POSY_LONGTEXT N_("Y offset, down from the top" )
124 #define OPACITY_TEXT N_("Opacity")
125 #define OPACITY_LONGTEXT N_("The opacity (inverse of transparency) of " \
126     "overlay text. 0 = transparent, 255 = totally opaque. " )
127 #define SIZE_TEXT N_("Font size, pixels")
128 #define SIZE_LONGTEXT N_("Specify the font size, in pixels, " \
129     "with -1 = use freetype-fontsize" )
130
131 #define COLOR_TEXT N_("Text Default Color")
132 #define COLOR_LONGTEXT N_("The color of overlay text. 1 byte for each color, hexadecimal. " \
133     "#000000 = all colors off, " \
134     "0xFF0000 = just Red, 0xFFFFFF = all color on [White]" )
135
136 #define POS_TEXT N_("Marquee position")
137 #define POS_LONGTEXT N_( \
138   "You can enforce the marquee position on the video " \
139   "(0=center, 1=left, 2=right, 4=top, 8=bottom, you can " \
140   "also use combinations of these values by adding them).")
141
142 static int pi_pos_values[] = { 0, 1, 2, 4, 8, 5, 6, 9, 10 };
143 static char *ppsz_pos_descriptions[] =
144      { N_("Center"), N_("Left"), N_("Right"), N_("Top"), N_("Bottom"),
145      N_("Top-Left"), N_("Top-Right"), N_("Bottom-Left"), N_("Bottom-Right") };
146
147 /*****************************************************************************
148  * Module descriptor
149  *****************************************************************************/
150 vlc_module_begin();
151     set_capability( "sub filter", 0 );
152     set_shortname( "RSS" );
153     set_callbacks( CreateFilter, DestroyFilter );
154     set_category( CAT_VIDEO );
155     set_subcategory( SUBCAT_VIDEO_SUBPIC );
156     add_string( "rss-urls", "rss", NULL, MSG_TEXT, MSG_LONGTEXT, VLC_FALSE );
157
158     set_section( N_("Position"), NULL );
159     add_integer( "rss-x", -1, NULL, POSX_TEXT, POSX_LONGTEXT, VLC_TRUE );
160     add_integer( "rss-y", 0, NULL, POSY_TEXT, POSY_LONGTEXT, VLC_TRUE );
161     add_integer( "rss-position", 5, NULL, POS_TEXT, POS_LONGTEXT, VLC_FALSE );
162         change_integer_list( pi_pos_values, ppsz_pos_descriptions, 0 );
163
164     set_section( N_("Font"), NULL );
165     /* 5 sets the default to top [1] left [4] */
166     add_integer_with_range( "rss-opacity", 255, 0, 255, NULL,
167         OPACITY_TEXT, OPACITY_LONGTEXT, VLC_FALSE );
168     add_integer( "rss-color", 0xFFFFFF, NULL, COLOR_TEXT, COLOR_LONGTEXT,
169                   VLC_FALSE );
170         change_integer_list( pi_color_values, ppsz_color_descriptions, 0 );
171     add_integer( "rss-size", -1, NULL, SIZE_TEXT, SIZE_LONGTEXT, VLC_FALSE );
172
173     set_section( N_("Misc"), NULL );
174     add_integer( "rss-speed", 100000, NULL, SPEED_TEXT, SPEED_LONGTEXT,
175                  VLC_FALSE );
176     add_integer( "rss-length", 60, NULL, LENGTH_TEXT, LENGTH_LONGTEXT,
177                  VLC_FALSE );
178     add_integer( "rss-ttl", 1800, NULL, TTL_TEXT, TTL_LONGTEXT, VLC_FALSE );
179
180     set_description( _("RSS feed display") );
181     add_shortcut( "rss" );
182 vlc_module_end();
183
184 /*****************************************************************************
185  * CreateFilter: allocates RSS video filter
186  *****************************************************************************/
187 static int CreateFilter( vlc_object_t *p_this )
188 {
189     filter_t *p_filter = (filter_t *)p_this;
190     filter_sys_t *p_sys;
191     int i_feed;
192
193     /* Allocate structure */
194     p_sys = p_filter->p_sys = malloc( sizeof( filter_sys_t ) );
195     if( p_sys == NULL )
196     {
197         msg_Err( p_filter, "out of memory" );
198         return VLC_ENOMEM;
199     }
200
201     vlc_mutex_init( p_filter, &p_sys->lock );
202     vlc_mutex_lock( &p_sys->lock );
203
204     p_sys->psz_urls = var_CreateGetString( p_filter, "rss-urls" );
205     p_sys->i_cur_feed = 0;
206     p_sys->i_cur_item = 0;
207     p_sys->i_cur_char = 0;
208     p_sys->i_feeds = 0;
209     p_sys->p_feeds = NULL;
210     p_sys->i_speed = var_CreateGetInteger( p_filter, "rss-speed" );
211     p_sys->i_length = var_CreateGetInteger( p_filter, "rss-length" );
212     p_sys->i_ttl = __MAX( 0, var_CreateGetInteger( p_filter, "rss-ttl" ) );
213     p_sys->psz_marquee = (char *)malloc( p_sys->i_length );
214
215     p_sys->p_style = malloc( sizeof( text_style_t ));
216     memcpy( p_sys->p_style, &default_text_style, sizeof( text_style_t ));
217
218     p_sys->i_xoff = var_CreateGetInteger( p_filter, "rss-x" );
219     p_sys->i_yoff = var_CreateGetInteger( p_filter, "rss-y" );
220     p_sys->i_pos = var_CreateGetInteger( p_filter, "rss-position" );
221     p_sys->p_style->i_font_alpha = 255 - var_CreateGetInteger( p_filter, "rss-opacity" );
222     p_sys->p_style->i_font_color = var_CreateGetInteger( p_filter, "rss-color" );
223     p_sys->p_style->i_font_size = var_CreateGetInteger( p_filter, "rss-size" );
224
225     if( FetchRSS( p_filter ) )
226     {
227         msg_Err( p_filter, "failed while fetching RSS ... too bad" );
228         vlc_mutex_unlock( &p_sys->lock );
229         return VLC_EGENERIC;
230     }
231     p_sys->t_last_update = time( NULL );
232
233     if( p_sys->i_feeds == 0 )
234     {
235         vlc_mutex_unlock( &p_sys->lock );
236         return VLC_EGENERIC;
237     }
238     for( i_feed=0; i_feed < p_sys->i_feeds; i_feed ++ )
239         if( p_sys->p_feeds[i_feed].i_items == 0 )
240         {
241             vlc_mutex_unlock( &p_sys->lock );
242             return VLC_EGENERIC;
243         }
244
245     /* Misc init */
246     p_filter->pf_sub_filter = Filter;
247     p_sys->last_date = (mtime_t)0;
248
249     vlc_mutex_unlock( &p_sys->lock );
250
251     return VLC_SUCCESS;
252 }
253 /*****************************************************************************
254  * DestroyFilter: destroy RSS video filter
255  *****************************************************************************/
256 static void DestroyFilter( vlc_object_t *p_this )
257 {
258     filter_t *p_filter = (filter_t *)p_this;
259     filter_sys_t *p_sys = p_filter->p_sys;
260
261     vlc_mutex_lock( &p_sys->lock );
262
263     if( p_sys->p_style ) free( p_sys->p_style );
264     if( p_sys->psz_marquee ) free( p_sys->psz_marquee );
265     free( p_sys->psz_urls );
266     FreeRSS( p_filter );
267     vlc_mutex_unlock( &p_sys->lock );
268     vlc_mutex_destroy( &p_sys->lock );
269     free( p_sys );
270
271     /* Delete the RSS variables */
272     var_Destroy( p_filter, "rss-urls" );
273     var_Destroy( p_filter, "rss-speed" );
274     var_Destroy( p_filter, "rss-length" );
275     var_Destroy( p_filter, "rss-ttl" );
276     var_Destroy( p_filter, "rss-x" );
277     var_Destroy( p_filter, "rss-y" );
278     var_Destroy( p_filter, "rss-position" );
279     var_Destroy( p_filter, "rss-color");
280     var_Destroy( p_filter, "rss-opacity");
281     var_Destroy( p_filter, "rss-size");
282 }
283
284 /****************************************************************************
285  * Filter: the whole thing
286  ****************************************************************************
287  * This function outputs subpictures at regular time intervals.
288  ****************************************************************************/
289 static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
290 {
291     filter_sys_t *p_sys = p_filter->p_sys;
292     subpicture_t *p_spu;
293     video_format_t fmt;
294
295     int i_feed, i_item;
296
297     vlc_mutex_lock( &p_sys->lock );
298
299     if( p_sys->last_date
300        + ( p_sys->i_cur_char == 0 && p_sys->i_cur_item == 0 ? 5 : 1 )
301            /* ( ... ? 5 : 1 ) means "wait more for the 1st char" */
302        * p_sys->i_speed > date )
303     {
304         vlc_mutex_unlock( &p_sys->lock );
305         return NULL;
306     }
307
308     /* Do we need to update the feeds ? */
309     if( p_sys->i_ttl
310         && time( NULL ) > p_sys->t_last_update + (time_t)p_sys->i_ttl )
311     {
312         msg_Dbg( p_filter, "Forcing update of all the RSS feeds" );
313         if( FetchRSS( p_filter ) )
314         {
315             msg_Err( p_filter, "failed while fetching RSS ... too bad" );
316             vlc_mutex_unlock( &p_sys->lock );
317             return NULL; /* FIXME : we most likely messed up all the data,
318                           * so we might need to do something about it */
319         }
320         p_sys->t_last_update = time( NULL );
321     }
322
323     p_sys->last_date = date;
324     p_sys->i_cur_char++;
325     if( p_sys->p_feeds[p_sys->i_cur_feed].p_items[p_sys->i_cur_item].psz_title[p_sys->i_cur_char] == 0 )
326     {
327         p_sys->i_cur_char = 0;
328         p_sys->i_cur_item++;
329         if( p_sys->i_cur_item >= p_sys->p_feeds[p_sys->i_cur_feed].i_items )
330         {
331             p_sys->i_cur_item = 0;
332             p_sys->i_cur_feed = (p_sys->i_cur_feed + 1)%p_sys->i_feeds;
333         }
334     }
335
336     p_spu = p_filter->pf_sub_buffer_new( p_filter );
337     if( !p_spu )
338     {
339         vlc_mutex_unlock( &p_sys->lock );
340         return NULL;
341     }
342
343     memset( &fmt, 0, sizeof(video_format_t) );
344     fmt.i_chroma = VLC_FOURCC('T','E','X','T');
345     fmt.i_aspect = 0;
346     fmt.i_width = 0;
347     fmt.i_height = 0;
348     fmt.i_x_offset = 0;
349     fmt.i_y_offset = 0;
350     p_spu->p_region = p_spu->pf_create_region( VLC_OBJECT(p_filter), &fmt );
351     if( !p_spu->p_region )
352     {
353         p_filter->pf_sub_buffer_del( p_filter, p_spu );
354         vlc_mutex_unlock( &p_sys->lock );
355         return NULL;
356     }
357
358     i_item = p_sys->i_cur_item;
359     i_feed = p_sys->i_cur_feed;
360     snprintf( p_sys->psz_marquee, p_sys->i_length, "%s : %s", p_sys->p_feeds[i_feed].psz_title, p_sys->p_feeds[i_feed].p_items[i_item].psz_title+p_sys->i_cur_char );
361     while( strlen( p_sys->psz_marquee ) < (unsigned int)p_sys->i_length )
362     {
363         i_item++;
364         if( i_item == p_sys->p_feeds[i_feed].i_items ) break;
365         snprintf( strchr( p_sys->psz_marquee, 0 ), p_sys->i_length - strlen( p_sys->psz_marquee ), " - %s", p_sys->p_feeds[i_feed].p_items[i_item].psz_title );
366     }
367
368     p_spu->p_region->psz_text = strdup(p_sys->psz_marquee);
369     p_spu->i_start = date;
370     p_spu->i_stop  = 0;
371     p_spu->b_ephemer = VLC_TRUE;
372
373     /*  where to locate the string: */
374     if( p_sys->i_xoff < 0 || p_sys->i_yoff < 0 )
375     {   /* set to one of the 9 relative locations */
376         p_spu->i_flags = p_sys->i_pos;
377         p_spu->i_x = 0;
378         p_spu->i_y = 0;
379         p_spu->b_absolute = VLC_FALSE;
380     }
381     else
382     {   /*  set to an absolute xy, referenced to upper left corner */
383         p_spu->i_flags = OSD_ALIGN_LEFT | OSD_ALIGN_TOP;
384         p_spu->i_x = p_sys->i_xoff;
385         p_spu->i_y = p_sys->i_yoff;
386         p_spu->b_absolute = VLC_TRUE;
387     }
388     p_spu->i_height = 1;
389     p_spu->p_region->p_style = p_sys->p_style;
390
391     vlc_mutex_unlock( &p_sys->lock );
392     return p_spu;
393 }
394
395 /****************************************************************************
396  * RSS related functions
397  ****************************************************************************
398  * You should always lock the p_filter mutex before using any of these
399  * functions
400  ***************************************************************************/
401
402 /****************************************************************************
403  * FetchRSS
404  ***************************************************************************/
405 static int FetchRSS( filter_t *p_filter)
406 {
407     filter_sys_t *p_sys = p_filter->p_sys;
408
409     stream_t *p_stream = NULL;
410     xml_t *p_xml = NULL;
411     xml_reader_t *p_xml_reader = NULL;
412
413     char *psz_eltname = NULL;
414     char *psz_eltvalue = NULL;
415     char *psz_feed = NULL;
416     char *psz_buffer = NULL;
417     char *psz_buffer_2 = NULL;
418
419     int i_feed;
420     int i_item;
421     int i_is_item;
422     int i_int;
423
424     FreeRSS( p_filter );
425     p_sys->i_feeds = 1;
426     i_int = 0;
427     while( p_sys->psz_urls[i_int] != 0 )
428         if( p_sys->psz_urls[i_int++] == '|' )
429             p_sys->i_feeds++;
430     p_sys->p_feeds = (struct rss_feed_t *)malloc( p_sys->i_feeds
431                                 * sizeof( struct rss_feed_t ) );
432
433     p_xml = xml_Create( p_filter );
434     if( !p_xml )
435     {
436         msg_Err( p_filter, "Failed to open XML parser" );
437         return 1;
438     }
439
440     psz_buffer = strdup( p_sys->psz_urls );
441     psz_buffer_2 = psz_buffer; /* keep track so we can free it */
442     for( i_feed = 0; i_feed < p_sys->i_feeds; i_feed++ )
443     {
444         struct rss_feed_t *p_feed = p_sys->p_feeds+i_feed;
445
446         if( psz_buffer == NULL ) break;
447         if( psz_buffer[0] == 0 ) psz_buffer++;
448         psz_feed = psz_buffer;
449         psz_buffer = strchr( psz_buffer, '|' );
450         if( psz_buffer != NULL ) psz_buffer[0] = 0;
451
452         p_feed->psz_title = NULL;
453         p_feed->psz_description = NULL;
454         p_feed->psz_link = NULL;
455         p_feed->i_items = 0;
456         p_feed->p_items = NULL;
457
458         msg_Dbg( p_filter, "Opening %s RSS feed ...", psz_feed );
459
460         p_stream = stream_UrlNew( p_filter, psz_feed );
461         if( !p_stream )
462         {
463             msg_Err( p_filter, "Failed to open %s for reading", psz_feed );
464             return 1;
465         }
466
467         p_xml_reader = xml_ReaderCreate( p_xml, p_stream );
468         if( !p_xml_reader )
469         {
470             msg_Err( p_filter, "Failed to open %s for parsing", psz_feed );
471             return 1;
472         }
473
474         i_item = 0;
475         i_is_item = VLC_FALSE;
476
477         while( xml_ReaderRead( p_xml_reader ) == 1 )
478         {
479             switch( xml_ReaderNodeType( p_xml_reader ) )
480             {
481                 // Error
482                 case -1:
483                     return 1;
484
485                 case XML_READER_STARTELEM:
486                     if( psz_eltname )
487                     {
488                         free( psz_eltname );
489                         psz_eltname = NULL;
490                     }
491                     psz_eltname = xml_ReaderName( p_xml_reader );
492                     if( !psz_eltname )
493                     {
494                         return 1;
495                     }
496 #                   ifdef RSS_DEBUG
497                     msg_Dbg( p_filter, "element name : %s", psz_eltname );
498 #                   endif
499                     if( !strcmp( psz_eltname, "item" ) )
500                     {
501                         i_is_item = VLC_TRUE;
502                         p_feed->i_items++;
503                         p_feed->p_items = (struct rss_item_t *)realloc( p_feed->p_items, p_feed->i_items * sizeof( struct rss_item_t ) );
504                         p_feed->p_items[p_feed->i_items-1].psz_title = NULL;
505                         p_feed->p_items[p_feed->i_items-1].psz_description
506                                                                      = NULL;
507                         p_feed->p_items[p_feed->i_items-1].psz_link = NULL;
508                     }
509                     break;
510
511                 case XML_READER_ENDELEM:
512                     if( psz_eltname )
513                     {
514                         free( psz_eltname );
515                         psz_eltname = NULL;
516                     }
517                     psz_eltname = xml_ReaderName( p_xml_reader );
518                     if( !psz_eltname )
519                     {
520                         return 1;
521                     }
522 #                   ifdef RSS_DEBUG
523                     msg_Dbg( p_filter, "element end : %s", psz_eltname );
524 #                   endif
525                     if( !strcmp( psz_eltname, "item" ) )
526                     {
527                         i_is_item = VLC_FALSE;
528                         i_item++;
529                     }
530                     free( psz_eltname );
531                     psz_eltname = NULL;
532                     break;
533
534                 case XML_READER_TEXT:
535                     psz_eltvalue = xml_ReaderValue( p_xml_reader );
536                     if( !psz_eltvalue )
537                     {
538                         return 1;
539                     }
540 #                   ifdef RSS_DEBUG
541                     msg_Dbg( p_filter, "  text : %s", psz_eltvalue );
542 #                   endif
543                     if( i_is_item == VLC_FALSE )
544                     {
545                         if( !strcmp( psz_eltname, "title" ) )
546                         {
547                             p_feed->psz_title = psz_eltvalue;
548                         }
549                         else if( !strcmp( psz_eltname, "link" ) )
550                         {
551                             p_feed->psz_link = psz_eltvalue;
552                         }
553                         else if( !strcmp( psz_eltname, "description" ) )
554                         {
555                             p_feed->psz_description = psz_eltvalue;
556                         }
557                         else
558                         {
559                             free( psz_eltvalue );
560                             psz_eltvalue = NULL;
561                         }
562                     }
563                     else
564                     {
565                         struct rss_item_t *p_item;
566                         p_item = p_feed->p_items+i_item;
567                         if( !strcmp( psz_eltname, "title" ) )
568                         {
569                             p_item->psz_title = psz_eltvalue;
570                         }
571                         else if( !strcmp( psz_eltname, "link" ) )
572                         {
573                             p_item->psz_link = psz_eltvalue;
574                         }
575                         else if( !strcmp( psz_eltname, "description" ) )
576                         {
577                             p_item->psz_description = psz_eltvalue;
578                         }
579                         else
580                         {
581                             free( psz_eltvalue );
582                             psz_eltvalue = NULL;
583                         }
584                     }
585                     break;
586             }
587         }
588
589         if( p_xml_reader && p_xml ) xml_ReaderDelete( p_xml, p_xml_reader );
590         if( p_stream ) stream_Delete( p_stream );
591         msg_Dbg( p_filter, "Done with %s RSS feed.", psz_feed );
592     }
593     free( psz_buffer_2 );
594     if( p_xml ) xml_Delete( p_xml );
595
596     return 0;
597 }
598
599 /****************************************************************************
600  * FreeRSS
601  ***************************************************************************/
602 static void FreeRSS( filter_t *p_filter)
603 {
604     filter_sys_t *p_sys = p_filter->p_sys;
605
606     struct rss_item_t *p_item;
607     struct rss_feed_t *p_feed;
608
609     int i_feed;
610     int i_item;
611
612     for( i_feed = 0; i_feed < p_sys->i_feeds; i_feed++ )
613     {
614         p_feed = p_sys->p_feeds+i_feed;
615         for( i_item = 0; i_item < p_feed->i_items; i_item++ )
616         {
617             p_item = p_feed->p_items+i_item;
618             free( p_item->psz_title );
619             free( p_item->psz_link );
620             free( p_item->psz_description );
621         }
622         free( p_feed->p_items );
623         free( p_feed->psz_title);
624         free( p_feed->psz_link );
625         free( p_feed->psz_description );
626     }
627     free( p_sys->p_feeds );
628     p_sys->i_feeds = 0;
629 }