summaryrefslogtreecommitdiff
path: root/apps/metadata/asap.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/metadata/asap.c')
-rw-r--r--apps/metadata/asap.c41
1 files changed, 21 insertions, 20 deletions
diff --git a/apps/metadata/asap.c b/apps/metadata/asap.c
index 128a18d642..ea9b201bff 100644
--- a/apps/metadata/asap.c
+++ b/apps/metadata/asap.c
@@ -104,9 +104,10 @@ static int ASAP_ParseDuration(const char *s)
104 return r; 104 return r;
105} 105}
106 106
107static bool read_asap_string(char* source,char** buf,char** buffer_end,char** dest) 107static bool read_asap_string(char* source, char** buf, char** buffer_end, char** dest)
108{ 108{
109 if(parse_text(*buf,source) == false) return false; 109 if(parse_text(*buf,source) == false)
110 return false;
110 111
111 /* set dest pointer */ 112 /* set dest pointer */
112 *dest = *buf; 113 *dest = *buf;
@@ -123,7 +124,7 @@ static bool read_asap_string(char* source,char** buf,char** buffer_end,char** de
123 return true; 124 return true;
124} 125}
125 126
126static bool parse_sap_header(int fd,struct mp3entry* id3,int file_len) 127static bool parse_sap_header(int fd, struct mp3entry* id3, int file_len)
127{ 128{
128 int module_index = 0; 129 int module_index = 0;
129 int sap_signature = -1; 130 int sap_signature = -1;
@@ -132,9 +133,9 @@ static bool parse_sap_header(int fd,struct mp3entry* id3,int file_len)
132 int i; 133 int i;
133 134
134 /* set defaults */ 135 /* set defaults */
135 int numSongs=1; 136 int numSongs = 1;
136 int defSong=0; 137 int defSong = 0;
137 int numChannels=1; 138 int numChannels = 1;
138 int durations[MAX_SONGS]; 139 int durations[MAX_SONGS];
139 int loops[MAX_SONGS]; 140 int loops[MAX_SONGS];
140 for (i = 0; i < MAX_SONGS; i++) { 141 for (i = 0; i < MAX_SONGS; i++) {
@@ -190,36 +191,36 @@ static bool parse_sap_header(int fd,struct mp3entry* id3,int file_len)
190 sap_signature = 1; 191 sap_signature = 1;
191 if (sap_signature == -1) 192 if (sap_signature == -1)
192 return false; 193 return false;
193 if (strcmp(line,"AUTHOR") == 0) 194 if (strcmp(line, "AUTHOR") == 0)
194 { 195 {
195 if(read_asap_string(p,&buffer,&buffer_end,&id3->artist) == false) 196 if(read_asap_string(p, &buffer, &buffer_end, &id3->artist) == false)
196 return false; 197 return false;
197 } 198 }
198 else if(strcmp(line,"NAME")==0) 199 else if(strcmp(line, "NAME") == 0)
199 { 200 {
200 if(read_asap_string(p,&buffer,&buffer_end,&id3->title) == false) 201 if(read_asap_string(p, &buffer, &buffer_end, &id3->title) == false)
201 return false; 202 return false;
202 } 203 }
203 else if(strcmp(line,"DATE")==0) 204 else if(strcmp(line, "DATE") == 0)
204 { 205 {
205 if(read_asap_string(p,&buffer,&buffer_end,&id3->year_string) == false) 206 if(read_asap_string(p, &buffer, &buffer_end, &id3->year_string) == false)
206 return false; 207 return false;
207 } 208 }
208 else if (strcmp(line,"SONGS")==0) 209 else if (strcmp(line, "SONGS") == 0)
209 { 210 {
210 if (parse_dec(&numSongs, p,1,MAX_SONGS) == false ) 211 if (parse_dec(&numSongs, p, 1, MAX_SONGS) == false )
211 return false; 212 return false;
212 } 213 }
213 else if (strcmp(line,"DEFSONG")==0) 214 else if (strcmp(line, "DEFSONG") == 0)
214 { 215 {
215 if (parse_dec(&defSong, p,0,MAX_SONGS) == false) 216 if (parse_dec(&defSong, p, 0, MAX_SONGS) == false)
216 return false; 217 return false;
217 } 218 }
218 else if (strcmp(line,"STEREO")==0) 219 else if (strcmp(line, "STEREO") == 0)
219 { 220 {
220 numChannels = 2; 221 numChannels = 2;
221 } 222 }
222 else if (strcmp(line,"TIME") == 0) 223 else if (strcmp(line, "TIME") == 0)
223 { 224 {
224 int durationTemp = ASAP_ParseDuration(p); 225 int durationTemp = ASAP_ParseDuration(p);
225 if (durationTemp < 0 || duration_index >= MAX_SONGS) 226 if (durationTemp < 0 || duration_index >= MAX_SONGS)
@@ -237,7 +238,7 @@ static bool parse_sap_header(int fd,struct mp3entry* id3,int file_len)
237 length = 180 * 1000; 238 length = 180 * 1000;
238 id3->length = length; 239 id3->length = length;
239 240
240 lseek(fd,0,SEEK_SET); 241 lseek(fd, 0, SEEK_SET);
241 return true; 242 return true;
242} 243}
243 244
@@ -247,7 +248,7 @@ bool get_asap_metadata(int fd, struct mp3entry* id3)
247 248
248 int filelength = filesize(fd); 249 int filelength = filesize(fd);
249 250
250 if(parse_sap_header(fd,id3,filelength) == false) 251 if(parse_sap_header(fd, id3, filelength) == false)
251 { 252 {
252 DEBUGF("parse sap header failed.\n"); 253 DEBUGF("parse sap header failed.\n");
253 return false; 254 return false;