Reorder functions in mp3_afh.c.
authorAndre Noll <maan@systemlinux.org>
Sun, 29 Jun 2008 12:38:02 +0000 (14:38 +0200)
committerAndre Noll <maan@systemlinux.org>
Sun, 29 Jun 2008 12:38:02 +0000 (14:38 +0200)
mp3_afh.c

index 7dda5496443c0cc07f53a23b26860b1dbdec6211..b8d3f5a9d3f44678c39bc4d0e0239c9a69ffa949 100644 (file)
--- a/mp3_afh.c
+++ b/mp3_afh.c
@@ -71,6 +71,60 @@ static const int mp3info_bitrate[2][3][14] = {
 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)
@@ -117,17 +171,6 @@ static int frame_length(struct mp3header *header)
                + 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))
@@ -222,49 +265,6 @@ static int mp3_seek_next_header(unsigned char *map, size_t numbytes, off_t *fpos
        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)
 {