aboutsummaryrefslogtreecommitdiff
path: root/src/frametab.gperf
diff options
context:
space:
mode:
Diffstat (limited to 'src/frametab.gperf')
-rw-r--r--src/frametab.gperf113
1 files changed, 26 insertions, 87 deletions
diff --git a/src/frametab.gperf b/src/frametab.gperf
index 80d60f9..7863d08 100644
--- a/src/frametab.gperf
+++ b/src/frametab.gperf
@@ -1,6 +1,6 @@
%{
/* This file is part of Idest.
- Copyright (C) 2009-2011, 2015 Sergey Poznyakoff
+ Copyright (C) 2009-2011, 2015, 2016 Sergey Poznyakoff
Idest is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -88,10 +88,7 @@ frame_field_from_string(struct id3_frame *frame, int n, const char *value)
return IDEST_ERR_NOFIELD;
if (type == ID3_FIELD_TYPE_TEXTENCODING) {
/* Special case */
- if (id3_field_settextencoding(field,
- latin1_option ?
- ID3_FIELD_TEXTENCODING_ISO_8859_1
- : ID3_FIELD_TEXTENCODING_UTF_8))
+ if (id3_field_settextencoding(field, textual_frame_encoding))
rc = IDEST_ERR_SET;
return rc;
}
@@ -117,7 +114,6 @@ frame_field_from_string(struct id3_frame *frame, int n, const char *value)
case ID3_FIELD_TYPE_LATIN1:
case ID3_FIELD_TYPE_LATIN1FULL:
- /* FIXME: Recode */
res = id3_field_setlatin1(field, (id3_latin1_t const *)value);
break;
@@ -127,34 +123,19 @@ frame_field_from_string(struct id3_frame *frame, int n, const char *value)
break;
case ID3_FIELD_TYPE_STRING:
- if (latin1_option)
- ucs4 = id3_latin1_ucs4duplicate(
- (const id3_latin1_t *)value);
- else
- ucs4 = id3_utf8_ucs4duplicate(
- (const id3_utf8_t *)value);
+ ucs4 = id3_utf8_ucs4duplicate((const id3_utf8_t *)value);
res = id3_field_setstring(field, ucs4);
free(ucs4);
break;
case ID3_FIELD_TYPE_STRINGFULL:
- if (latin1_option)
- ucs4 = id3_latin1_ucs4duplicate(
- (const id3_latin1_t *)value);
- else
- ucs4 = id3_utf8_ucs4duplicate(
- (const id3_utf8_t *)value);
+ ucs4 = id3_utf8_ucs4duplicate((const id3_utf8_t *)value);
res = id3_field_setfullstring(field, ucs4);
free(ucs4);
break;
case ID3_FIELD_TYPE_STRINGLIST:
- if (latin1_option)
- ucs4 = id3_latin1_ucs4duplicate(
- (const id3_latin1_t *)value);
- else
- ucs4 = id3_utf8_ucs4duplicate(
- (const id3_utf8_t *)value);
+ ucs4 = id3_utf8_ucs4duplicate((const id3_utf8_t *)value);
res = id3_field_setstrings(field, 1, &ucs4);
free(ucs4);
break;
@@ -200,10 +181,7 @@ frame_field_from_rawdata(struct id3_frame *frame, int n,
return IDEST_ERR_NOFIELD;
if (type == ID3_FIELD_TYPE_TEXTENCODING) {
/* Special case */
- if (id3_field_settextencoding(field,
- latin1_option ?
- ID3_FIELD_TEXTENCODING_ISO_8859_1
- : ID3_FIELD_TEXTENCODING_UTF_8))
+ if (id3_field_settextencoding(field, textual_frame_encoding))
rc = IDEST_ERR_SET;
return rc;
}
@@ -224,7 +202,6 @@ frame_field_from_rawdata(struct id3_frame *frame, int n,
case ID3_FIELD_TYPE_LATIN1:
case ID3_FIELD_TYPE_LATIN1FULL:
- /* FIXME: Recode */
res = id3_field_setlatin1(field, (id3_latin1_t const *)value);
break;
@@ -234,34 +211,19 @@ frame_field_from_rawdata(struct id3_frame *frame, int n,
break;
case ID3_FIELD_TYPE_STRING:
- if (latin1_option)
- ucs4 = id3_latin1_ucs4duplicate(
- (const id3_latin1_t *)value);
- else
- ucs4 = id3_utf8_ucs4duplicate(
- (const id3_utf8_t *)value);
+ ucs4 = id3_utf8_ucs4duplicate((const id3_utf8_t *)value);
res = id3_field_setstring(field, ucs4);
free(ucs4);
break;
case ID3_FIELD_TYPE_STRINGFULL:
- if (latin1_option)
- ucs4 = id3_latin1_ucs4duplicate(
- (const id3_latin1_t *)value);
- else
- ucs4 = id3_utf8_ucs4duplicate(
- (const id3_utf8_t *)value);
+ ucs4 = id3_utf8_ucs4duplicate((const id3_utf8_t *)value);
res = id3_field_setfullstring(field, ucs4);
free(ucs4);
break;
case ID3_FIELD_TYPE_STRINGLIST:
- if (latin1_option)
- ucs4 = id3_latin1_ucs4duplicate(
- (const id3_latin1_t *)value);
- else
- ucs4 = id3_utf8_ucs4duplicate(
- (const id3_utf8_t *)value);
+ ucs4 = id3_utf8_ucs4duplicate((const id3_utf8_t *)value);
res = id3_field_setstrings(field, 1, &ucs4);
free(ucs4);
break;
@@ -340,12 +302,7 @@ comm_encode(struct id3_frame *frame, const struct ed_item *item)
return rc;
field = id3_frame_field(frame, 3);
- if (latin1_option)
- ucs4 = id3_latin1_ucs4duplicate(
- (const id3_latin1_t *) item->value);
- else
- ucs4 = id3_utf8_ucs4duplicate(
- (const id3_utf8_t *) item->value);
+ ucs4 = id3_utf8_ucs4duplicate((const id3_utf8_t *) item->value);
if (id3_field_setfullstring(field, ucs4))
rc = IDEST_ERR_SET;
free(ucs4);
@@ -358,12 +315,11 @@ comm_decode(struct ed_item *item, struct id3_frame const *frame)
int rc;
union id3_field *field;
- if (rc = decode_qv(item, frame, 1, 2))
+ if ((rc = decode_qv(item, frame, 1, 2)))
return rc;
field = id3_frame_field(frame, 3);
if (!field)
return IDEST_ERR_NOFIELD;
- /* FIXME: Recode as necessary */
item->value = field_to_string(field, 0);
return 0;
@@ -374,19 +330,12 @@ text_encode(struct id3_frame *frame, struct ed_item const *item)
{
const char *value = item->value;
union id3_field *field;
- enum id3_field_textencoding encoding =
- (latin1_option ? ID3_FIELD_TEXTENCODING_ISO_8859_1
- : ID3_FIELD_TEXTENCODING_UTF_8);
id3_ucs4_t *ucs4;
-
+
field = id3_frame_field(frame, 0);
- id3_field_settextencoding(field, encoding);
+ id3_field_settextencoding(field, textual_frame_encoding);
- if (latin1_option)
- ucs4 = id3_latin1_ucs4duplicate((const id3_latin1_t *) value);
- else
- ucs4 = id3_utf8_ucs4duplicate((const id3_utf8_t *)value);
-
+ ucs4 = id3_utf8_ucs4duplicate((const id3_utf8_t *)value);
field = id3_frame_field(frame, 1);
id3_field_setstrings(field, 1, &ucs4);
@@ -398,20 +347,18 @@ static int
text_decode(struct ed_item *item, struct id3_frame const *frame)
{
int isgenre = strcmp(frame->id, ID3_FRAME_GENRE) == 0;
- enum id3_field_textencoding encoding;
union id3_field *field;
-
- field = id3_frame_field(frame, 0);
- if (!field)
- return IDEST_ERR_NOFIELD;
- encoding = id3_field_gettextencoding(field);
- if (encoding == -1)
- return IDEST_ERR_BADCONV;
+ char *str;
+ int rc;
+
field = id3_frame_field(frame, 1);
if (!field)
return IDEST_ERR_NOFIELD;
- /* FIXME: Recode as necessary */
- item->value = field_to_string(field, isgenre);
+ str = field_to_string(field, isgenre);
+ rc = utf8_convert(idest_conv_decode, str, &item->value);
+ free(str);
+ if (rc)
+ return IDEST_ERR_BADCONV;
return 0;
}
@@ -447,12 +394,7 @@ txxx_encode(struct id3_frame *frame, const struct ed_item *item)
return rc;
field = id3_frame_field(frame, 2);
- if (latin1_option)
- ucs4 = id3_latin1_ucs4duplicate(
- (const id3_latin1_t *) item->value);
- else
- ucs4 = id3_utf8_ucs4duplicate(
- (const id3_utf8_t *) item->value);
+ ucs4 = id3_utf8_ucs4duplicate((const id3_utf8_t *) item->value);
if (id3_field_setstring(field, ucs4))
rc = IDEST_ERR_SET;
free(ucs4);
@@ -465,12 +407,11 @@ txxx_decode(struct ed_item *item, struct id3_frame const *frame)
int rc;
union id3_field *field;
- if (rc = decode_qv(item, frame, 1, 1))
+ if ((rc = decode_qv(item, frame, 1, 1)))
return rc;
field = id3_frame_field(frame, 2);
if (!field)
return IDEST_ERR_NOFIELD;
- /* FIXME: Recode as necessary */
item->value = field_to_string(field, 0);
return 0;
@@ -509,7 +450,6 @@ url_decode(struct ed_item *item, struct id3_frame const *frame)
field = id3_frame_field(frame, 0);
if (!field)
return IDEST_ERR_NOFIELD;
- /* FIXME: Recode as necessary */
item->value = field_to_string(field, 0);
return 0;
@@ -553,13 +493,12 @@ wxxx_decode(struct ed_item *item, struct id3_frame const *frame)
int rc;
union id3_field *field;
- if (rc = decode_qv(item, frame, 1, 1))
+ if ((rc = decode_qv(item, frame, 1, 1)))
return rc;
field = id3_frame_field(frame, 2);
if (!field)
return IDEST_ERR_NOFIELD;
- /* FIXME: Recode as necessary */
item->value = field_to_string(field, 0);
return 0;
@@ -603,7 +542,7 @@ apic_decode(struct ed_item *item, struct id3_frame const *frame)
int rc;
union id3_field *field;
- if (rc = decode_qv(item, frame, 1, 3))
+ if ((rc = decode_qv(item, frame, 1, 3)))
return rc;
field = id3_frame_field(frame, 4);

Return to:

Send suggestions and report system problems to the System administrator.