static const int frame_size_index[] = {24000, 72000, 72000};
static const char *mode_text[] = {"stereo", "joint stereo", "dual channel", "mono", "invalid"};
+/*
+ * Remove trailing whitespace from the end of a string
+ */
+static char *unpad(char *string)
+{
+ char *pos = string + strlen(string) - 1;
+ while (para_isspace(pos[0]))
+ (pos--)[0] = 0;
+ return string;
+}
+
+static char *mp3_get_id3(unsigned char *map, size_t numbytes)
+{
+ char title[31], artist[31], album[31], year[5], comment[31];
+ off_t fpos;
+
+ if (numbytes < 128 || strncmp("TAG", (char *)map + numbytes - 128, 3)) {
+ PARA_DEBUG_LOG("no id3 v1 tag\n");
+ return make_message("%s: (no id3 v1 tag)\n%s:\n",
+ status_item_list[SI_TAGINFO1],
+ status_item_list[SI_TAGINFO2]);
+ }
+ fpos = numbytes - 125;
+ memcpy(title, map + fpos, 30);
+ fpos += 30;
+ title[30] = '\0';
+ memcpy(artist, map + fpos, 30);
+ fpos += 30;
+ artist[30] = '\0';
+ memcpy(album, map + fpos, 30);
+ fpos += 30;
+ album[30] = '\0';
+ memcpy(year, map + fpos, 4);
+ fpos += 4;
+ year[4] = '\0';
+ memcpy(comment, map + fpos, 30);
+ comment[30] = '\0';
+ unpad(title);
+ unpad(artist);
+ unpad(album);
+ unpad(year);
+ unpad(comment);
+ return make_message("%s: %s, by %s\n" /* taginfo1 */
+ "%s: A: %s, Y: %s, C: %s\n", /* taginfo 2*/
+ status_item_list[SI_TAGINFO1],
+ *title? title : "(title tag not set)",
+ *artist? artist : "(artist tag not set)",
+ status_item_list[SI_TAGINFO2],
+ *album? album : "(album tag not set)",
+ *year? year : "????",
+ *comment? comment : "(comment tag not set)"
+ );
+}
+
static int header_frequency(struct mp3header *h)
{
if (h->version > 2 || h->freq > 3)
+ header->padding;
}
-/*
- * Remove trailing whitespace from the end of a string
- */
-static char *unpad(char *string)
-{
- char *pos = string + strlen(string) - 1;
- while (para_isspace(pos[0]))
- (pos--)[0] = 0;
- return string;
-}
-
static int compare_headers(struct mp3header *h1,struct mp3header *h2)
{
if ((*(uint*)h1) == (*(uint*)h2))
return 0;
}
-static char *mp3_get_id3(unsigned char *map, size_t numbytes)
-{
- char title[31], artist[31], album[31], year[5], comment[31];
- off_t fpos;
-
- if (numbytes < 128 || strncmp("TAG", (char *)map + numbytes - 128, 3)) {
- PARA_DEBUG_LOG("no id3 v1 tag\n");
- return make_message("%s: (no id3 v1 tag)\n%s:\n",
- status_item_list[SI_TAGINFO1],
- status_item_list[SI_TAGINFO2]);
- }
- fpos = numbytes - 125;
- memcpy(title, map + fpos, 30);
- fpos += 30;
- title[30] = '\0';
- memcpy(artist, map + fpos, 30);
- fpos += 30;
- artist[30] = '\0';
- memcpy(album, map + fpos, 30);
- fpos += 30;
- album[30] = '\0';
- memcpy(year, map + fpos, 4);
- fpos += 4;
- year[4] = '\0';
- memcpy(comment, map + fpos, 30);
- comment[30] = '\0';
- unpad(title);
- unpad(artist);
- unpad(album);
- unpad(year);
- unpad(comment);
- return make_message("%s: %s, by %s\n" /* taginfo1 */
- "%s: A: %s, Y: %s, C: %s\n", /* taginfo 2*/
- status_item_list[SI_TAGINFO1],
- *title? title : "(title tag not set)",
- *artist? artist : "(artist tag not set)",
- status_item_list[SI_TAGINFO2],
- *album? album : "(album tag not set)",
- *year? year : "????",
- *comment? comment : "(comment tag not set)"
- );
-}
-
static int find_valid_start(unsigned char *map, size_t numbytes, off_t *fpos,
struct mp3header *header)
{