/* * Function id3_get_text (frame) * * Return string contents of frame. * */ char *id3_get_text(struct id3_frame *frame) { int offset = 0; /* Type check */ if (frame->fr_desc->fd_idstr[0] != 'T') return NULL; /* Check if frame is compressed */ if (id3_decompress_frame(frame) == -1) return NULL; if (frame->fr_desc->fd_id == ID3_TXXX) { /* * This is a user defined text frame. Skip the description. */ offset = id3_string_size(ID3_TEXT_FRAME_ENCODING(frame), ID3_TEXT_FRAME_PTR(frame)); if (offset >= frame->fr_size) return NULL; } return id3_string_decode(ID3_TEXT_FRAME_ENCODING(frame), ID3_TEXT_FRAME_PTR(frame) + offset); }
/* * Function id3_get_comment(frame) * * Return string contents of a comment frame. * */ char *id3_get_comment(struct id3_frame *frame) { int offset; /* Type check */ if (frame->fr_desc->fd_id != ID3_COMM) return NULL; /* Check if frame is compressed */ if (id3_decompress_frame(frame) == -1) return NULL; if (frame->fr_size < 5) return NULL; /* Skip language id */ offset = 3; /* Skip the description */ offset += id3_string_size(ID3_TEXT_FRAME_ENCODING(frame), ID3_TEXT_FRAME_PTR(frame) + offset); if (offset >= frame->fr_size) return NULL; return id3_string_decode(ID3_TEXT_FRAME_ENCODING(frame), ID3_TEXT_FRAME_PTR(frame) + offset); }
static GSList* id3_get_content_v24(struct id3_frame *frame) { GSList *list = NULL; int offset = 0; while (offset < frame->fr_size - 1) { int num; char *input, *endptr; input = id3_string_decode(ID3_TEXT_FRAME_ENCODING(frame), ID3_TEXT_FRAME_PTR(frame) + offset); if (!input) break; /* Get ID3v1 genre number */ num = strtol(input, &endptr, 10); if (endptr && endptr != input && *endptr == '\0' && num >= 0 && num < 256) list = push_element(list, num, NULL); else if (!strcmp(input, "RX")) list = push_element(list, -1, _("Remix")); else if (!strcmp(input, "CR")) list = push_element(list, -1, _("Cover")); else list = push_element(list, -1, input); offset += id3_string_size(ID3_TEXT_FRAME_ENCODING(frame), ID3_TEXT_FRAME_PTR(frame) + offset); } return list; }