xspf_c  1.2.0
xspf_c.h
Go to the documentation of this file.
1 /*
2  * xspf_c - Simple C interface for libxspf
3  *
4  * Copyright (C) 2007, Ed Schouten / Xiph.Org Foundation
5  * Copyright (C) 2008, Sebastian Pipping / Xiph.Org Foundation
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * * Redistributions of source code must retain the above
13  * copyright notice, this list of conditions and the following
14  * disclaimer.
15  *
16  * * Redistributions in binary form must reproduce the above
17  * copyright notice, this list of conditions and the following
18  * disclaimer in the documentation and/or other materials
19  * provided with the distribution.
20  *
21  * * Neither the name of the Xiph.Org Foundation nor the names of
22  * its contributors may be used to endorse or promote products
23  * derived from this software without specific prior written
24  * permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
29  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
30  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
31  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
32  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
33  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
35  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
37  * OF THE POSSIBILITY OF SUCH DAMAGE.
38  *
39  * Ed Schouten <ed@fxq.nl>
40  * Sebastian Pipping <sping@xiph.org>
41  */
47 #ifndef XSPF_C_H
48 #define XSPF_C_H
49 
54 struct xspf_mvalue {
58  char *value;
62  struct xspf_mvalue *next;
63 
67  void *pdata;
68 };
69 
73 struct xspf_track {
77  char *creator;
81  char *title;
85  char *album;
86 
90  int duration;
94  int tracknum;
95 
104 
108  struct xspf_track *next;
109 
113  void *pdata;
114 };
115 
119 struct xspf_list {
123  char *license;
127  char *location;
131  char *identifier;
132 
137 
141  void *pdata;
142 };
143 
147 #define XSPF_LIST_FOREACH_TRACK(l,t) \
148  for ((t) = (l)->tracks; (t) != NULL; (t) = (t)->next)
149 
152 #define XSPF_TRACK_FOREACH_LOCATION(t,l) \
153  for ((l) = (t)->locations; (l) != NULL; (l) = (l)->next)
154 
157 #define XSPF_TRACK_FOREACH_IDENTIFIER(t,i) \
158  for ((i) = (t)->identifiers; (i) != NULL; (i) = (i)->next)
159 
163 struct xspf_list *xspf_parse(char const *filename, char const *baseuri);
168 struct xspf_list *xspf_parse_memory(char const *memory, int len_bytes, char const *baseuri);
172 struct xspf_list *xspf_new(void);
176 void xspf_free(struct xspf_list *list);
181 void xspf_setvalue(char **str, char const *nstr);
189  struct xspf_mvalue **mvalue);
197  struct xspf_track **track);
201 int xspf_write(struct xspf_list *list, char const *filename, char const *baseuri);
202 
203 #endif /* !XSPF_C_H */
struct xspf_mvalue * xspf_new_mvalue_before(struct xspf_mvalue **mvalue)
Insert a new mvalue to the linked list before the specified one. This routine can also be used to ins...
Definition: xspf_c.cpp:286
struct xspf_list * xspf_parse_memory(char const *memory, int len_bytes, char const *baseuri)
Parse an XSPF file from memory.
Definition: xspf_c.cpp:206
void * pdata
Private data that can be freely used.
Definition: xspf_c.h:141
int tracknum
Track number.
Definition: xspf_c.h:94
Linked list for values inside tracks or lists with string values.
Definition: xspf_c.h:54
struct xspf_mvalue * identifiers
Unique track identifiers.
Definition: xspf_c.h:103
char * license
Playlist&#39;s license.
Definition: xspf_c.h:123
struct xspf_list * xspf_parse(char const *filename, char const *baseuri)
Parse an XSPF file by filename.
Definition: xspf_c.cpp:185
Single track in an XSPF list.
Definition: xspf_c.h:73
int duration
Track duration in milliseconds.
Definition: xspf_c.h:90
struct xspf_track * tracks
Linked list of tracks inside the playlist.
Definition: xspf_c.h:136
char * album
Album or collection of origin.
Definition: xspf_c.h:85
Parsed XSPF file.
Definition: xspf_c.h:119
void * pdata
Private data that can be freely used.
Definition: xspf_c.h:113
char * identifier
Playlist&#39;s unique indentifier.
Definition: xspf_c.h:131
char * title
Track&#39;s display name.
Definition: xspf_c.h:81
struct xspf_mvalue * next
Pointer to next object in the list.
Definition: xspf_c.h:62
void * pdata
Private data that can be freely used.
Definition: xspf_c.h:67
char * location
Playlist&#39;s file location.
Definition: xspf_c.h:127
struct xspf_list * xspf_new(void)
Create a new empty XSPF playlist.
Definition: xspf_c.cpp:227
char * creator
Track&#39;s creator.
Definition: xspf_c.h:77
struct xspf_track * xspf_new_track_before(struct xspf_track **track)
Insert a new track to the linked list before the specified one. This routine can also be used to inse...
Definition: xspf_c.cpp:300
void xspf_setvalue(char **str, char const *nstr)
Set or overwrite a value in the xspf_list, xspf_track or xspf_mvalue structures. Passing NULL will un...
Definition: xspf_c.cpp:268
int xspf_write(struct xspf_list *list, char const *filename, char const *baseuri)
Write the Xspf playlist to a file.
Definition: xspf_c.cpp:320
struct xspf_mvalue * locations
Track&#39;s file locations.
Definition: xspf_c.h:99
struct xspf_track * next
Pointer to next track.
Definition: xspf_c.h:108
void xspf_free(struct xspf_list *list)
Free the parser results.
Definition: xspf_c.cpp:242
char * value
Value of the current list entry.
Definition: xspf_c.h:58