aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2015-11-05 23:20:23 +0200
committerSergey Poznyakoff <gray@gnu.org>2015-11-05 23:20:23 +0200
commit6f8dc538dab2a9284802b63e80fd4f03bb0dff34 (patch)
tree387372a6dc1c8e04aa81e19b19820c8d75351f67
parent353839b7a29a53aa754b98b02ede449c737a873a (diff)
downloadidest-6f8dc538dab2a9284802b63e80fd4f03bb0dff34.tar.gz
idest-6f8dc538dab2a9284802b63e80fd4f03bb0dff34.tar.bz2
Bugfixes.
1. Fix --convert option so it can be used to remove unnecessary ID3 formats (e.g. --convert=2). 2. Fix processing of unknown frames in Guile code. 3. Fix setpic and pic modules. * scheme/idest/batch/setpic.scm (read-picture): Use binary i/o. * scheme/idest/format/pic.scm (save-picture): Likewise. * scheme/idest/list-modules.scm: Minor changes. * src/frametab.gperf (frame_field_from_rawdata): New function. * src/getopt.m4: Update copyright years. * src/guile.c (set_frame_from_rawdata): Use frame_field_from_rawdata. * src/idest.h (frame_field_from_rawdata): New proto. * src/idop.c (set_tag_options): Always call id3_tag_options.
-rw-r--r--scheme/idest/batch/setpic.scm24
-rw-r--r--scheme/idest/format/pic.scm27
-rw-r--r--scheme/idest/list-modules.scm6
-rw-r--r--src/frametab.gperf111
-rw-r--r--src/getopt.m44
-rw-r--r--src/guile.c18
-rw-r--r--src/idest.h6
-rw-r--r--src/idop.c9
8 files changed, 167 insertions, 38 deletions
diff --git a/scheme/idest/batch/setpic.scm b/scheme/idest/batch/setpic.scm
index c0670a3..834a571 100644
--- a/scheme/idest/batch/setpic.scm
+++ b/scheme/idest/batch/setpic.scm
@@ -1,3 +1,3 @@
1;; This file is part of Idest 1;; This file is part of Idest
2;; Copyright (C) 2011 Sergey Poznyakoff 2;; Copyright (C) 2011, 2015 Sergey Poznyakoff
3;; 3;;
@@ -18,3 +18,4 @@
18 18
19(use-modules (ice-9 getopt-long)) 19(use-modules (ice-9 getopt-long)
20 (rnrs io ports))
20 21
@@ -28,13 +29,12 @@
28 (lambda () 29 (lambda ()
29 (with-input-from-file 30 (let ((port (open-file-input-port file)))
30 file 31 (let ((get-byte (lambda () (get-u8 port))))
31 (lambda () 32 (let loop ((n (get-byte)))
32 (let loop ((chr (read-char)))
33 (cond 33 (cond
34 ((not (eof-object? chr)) 34 ((not (eof-object? n))
35 (let ((n (char->integer chr))) 35 (if (< n 16)
36 (if (< n 16) 36 (display "0"))
37 (display "0")) 37 (display (number->string n 16))
38 (display (number->string n 16))) 38 (loop (get-byte))))))
39 (loop (read-char)))))))))) 39 (close-port port)))))
40 40
diff --git a/scheme/idest/format/pic.scm b/scheme/idest/format/pic.scm
index 0e42f25..5e831fb 100644
--- a/scheme/idest/format/pic.scm
+++ b/scheme/idest/format/pic.scm
@@ -1,3 +1,3 @@
1;; This file is part of Idest 1;; This file is part of Idest
2;; Copyright (C) 2011 Sergey Poznyakoff 2;; Copyright (C) 2011, 2015 Sergey Poznyakoff
3;; 3;;
@@ -19,2 +19,3 @@
19(use-modules (ice-9 getopt-long) 19(use-modules (ice-9 getopt-long)
20 (rnrs io ports)
20 (srfi srfi-1)) 21 (srfi srfi-1))
@@ -74,2 +75,19 @@
74(define (save-picture name data) 75(define (save-picture name data)
76 (let ((port (open-file-output-port name)))
77 (for-each
78 (lambda (c) (put-u8 port c))
79 (let string->bytelist ((str data)
80 (bytelist '()))
81 (cond
82 ((string-null? str)
83 (reverse bytelist))
84 (else
85 (string->bytelist
86 (substring str 2)
87 (cons
88 (string->number (substring str 0 2) 16)
89 bytelist))))))
90 (close-port port)))
91
92(define (save-picture-0 name data)
75 (with-output-to-file 93 (with-output-to-file
@@ -78,3 +96,3 @@
78 (for-each 96 (for-each
79 write-char 97 (lambda (c) (put-u8 (current-output-port) c))
80 (let string->bytelist ((str data) 98 (let string->bytelist ((str data)
@@ -88,4 +106,3 @@
88 (cons 106 (cons
89 (integer->char 107 (string->number (substring str 0 2) 16)
90 (string->number (substring str 0 2) 16))
91 bytelist))))))))) 108 bytelist)))))))))
@@ -206,2 +223,2 @@
206 223
207 \ No newline at end of file 224
diff --git a/scheme/idest/list-modules.scm b/scheme/idest/list-modules.scm
index c69d331..880dbf8 100644
--- a/scheme/idest/list-modules.scm
+++ b/scheme/idest/list-modules.scm
@@ -1,3 +1,3 @@
1;; This file is part of Idest 1;; This file is part of Idest
2;; Copyright (C) 2011 Sergey Poznyakoff 2;; Copyright (C) 2011, 2015 Sergey Poznyakoff
3;; 3;;
@@ -94,3 +94,3 @@
94 94
95 ;; Try out each candidate and print ist name, directory and description 95 ;; Try out each candidate and print its name, directory and description
96 ;; if it happens to be a valid idest format module. 96 ;; if it happens to be a valid idest format module.
@@ -113,3 +113,3 @@
113 (format #t " (~A)" (cdr candidate))) 113 (format #t " (~A)" (cdr candidate)))
114 ; A colon, and description (if any 114 ; A colon, and description (if any)
115 (format #t ": ~A~%" 115 (format #t ": ~A~%"
diff --git a/src/frametab.gperf b/src/frametab.gperf
index e716954..80d60f9 100644
--- a/src/frametab.gperf
+++ b/src/frametab.gperf
@@ -2,3 +2,3 @@
2/* This file is part of Idest. 2/* This file is part of Idest.
3 Copyright (C) 2009-2011 Sergey Poznyakoff 3 Copyright (C) 2009-2011, 2015 Sergey Poznyakoff
4 4
@@ -88,3 +88,3 @@ frame_field_from_string(struct id3_frame *frame, int n, const char *value)
88 return IDEST_ERR_NOFIELD; 88 return IDEST_ERR_NOFIELD;
89 if (frametype->fields[n] == ID3_FIELD_TYPE_TEXTENCODING) { 89 if (type == ID3_FIELD_TYPE_TEXTENCODING) {
90 /* Special case */ 90 /* Special case */
@@ -188,2 +188,109 @@ frame_field_from_string(struct id3_frame *frame, int n, const char *value)
188 188
189int
190frame_field_from_rawdata(struct id3_frame *frame, int n,
191 enum id3_field_type type,
192 const char *value)
193{
194 int rc = 0, res = 0;
195 union id3_field *field;
196 id3_ucs4_t *ucs4;
197
198 field = id3_frame_field(frame, n);
199 if (!field)
200 return IDEST_ERR_NOFIELD;
201 if (type == ID3_FIELD_TYPE_TEXTENCODING) {
202 /* Special case */
203 if (id3_field_settextencoding(field,
204 latin1_option ?
205 ID3_FIELD_TEXTENCODING_ISO_8859_1
206 : ID3_FIELD_TEXTENCODING_UTF_8))
207 rc = IDEST_ERR_SET;
208 return rc;
209 }
210
211 switch (type) {
212 case ID3_FIELD_TYPE_INT8:
213 case ID3_FIELD_TYPE_INT16:
214 case ID3_FIELD_TYPE_INT24:
215 case ID3_FIELD_TYPE_INT32: {
216 char *p;
217 signed long number = strtoul(value, &p, 10);
218 if (*p)
219 rc = IDEST_ERR_BADCONV;
220 else
221 res = id3_field_setint(field, number);
222 break;
223 }
224
225 case ID3_FIELD_TYPE_LATIN1:
226 case ID3_FIELD_TYPE_LATIN1FULL:
227 /* FIXME: Recode */
228 res = id3_field_setlatin1(field, (id3_latin1_t const *)value);
229 break;
230
231 case ID3_FIELD_TYPE_LATIN1LIST:
232 /* FIXME */
233 rc = IDEST_ERR_NOTSUPP;
234 break;
235
236 case ID3_FIELD_TYPE_STRING:
237 if (latin1_option)
238 ucs4 = id3_latin1_ucs4duplicate(
239 (const id3_latin1_t *)value);
240 else
241 ucs4 = id3_utf8_ucs4duplicate(
242 (const id3_utf8_t *)value);
243 res = id3_field_setstring(field, ucs4);
244 free(ucs4);
245 break;
246
247 case ID3_FIELD_TYPE_STRINGFULL:
248 if (latin1_option)
249 ucs4 = id3_latin1_ucs4duplicate(
250 (const id3_latin1_t *)value);
251 else
252 ucs4 = id3_utf8_ucs4duplicate(
253 (const id3_utf8_t *)value);
254 res = id3_field_setfullstring(field, ucs4);
255 free(ucs4);
256 break;
257
258 case ID3_FIELD_TYPE_STRINGLIST:
259 if (latin1_option)
260 ucs4 = id3_latin1_ucs4duplicate(
261 (const id3_latin1_t *)value);
262 else
263 ucs4 = id3_utf8_ucs4duplicate(
264 (const id3_utf8_t *)value);
265 res = id3_field_setstrings(field, 1, &ucs4);
266 free(ucs4);
267 break;
268
269 case ID3_FIELD_TYPE_LANGUAGE:
270 res = id3_field_setlanguage(field, value);
271 break;
272
273 case ID3_FIELD_TYPE_FRAMEID:
274 res = id3_field_setframeid(field, value);
275 break;
276
277 case ID3_FIELD_TYPE_DATE:
278 /* FIXME: Convert and copy 8 bytes into
279 field->immediate.value */
280 rc = IDEST_ERR_NOTSUPP;
281 break;
282
283 case ID3_FIELD_TYPE_INT32PLUS:
284 case ID3_FIELD_TYPE_BINARYDATA:
285 rc = field_binary_from_string(field, value);
286 break;
287
288 default:
289 rc = IDEST_ERR_BADTYPE;
290 }
291 if (rc == 0 && res)
292 rc = IDEST_ERR_SET;