Mercurial > audlegacy-plugins
changeset 399:597c89a37d07 trunk
[svn] - add DYEAR and DGENRE support.
author | yaz |
---|---|
date | Thu, 28 Dec 2006 02:57:42 -0800 |
parents | 7e4e672de0dc |
children | de2413cc592e |
files | ChangeLog src/cdaudio/cdaudio.c src/cdaudio/cddb.c src/cdaudio/cdinfo.c src/cdaudio/cdinfo.h |
diffstat | 5 files changed, 100 insertions(+), 66 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Sun Dec 24 07:08:26 2006 -0800 +++ b/ChangeLog Thu Dec 28 02:57:42 2006 -0800 @@ -1,3 +1,11 @@ +2006-12-24 15:08:26 +0000 Michael Hanselmann <hansmi@forkbomb.ch> + revision [872] + Add .s3m to allowed extensions, reported by Chainsaw. + + trunk/src/modplug/plugin.cxx | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + + 2006-12-23 22:46:28 +0000 Michael Hanselmann <hansmi@forkbomb.ch> revision [870] Fix endian issues on ppc32.
--- a/src/cdaudio/cdaudio.c Sun Dec 24 07:08:26 2006 -0800 +++ b/src/cdaudio/cdaudio.c Thu Dec 28 02:57:42 2006 -0800 @@ -1058,6 +1058,9 @@ if (!tuple->track_name) tuple->track_name = g_strdup_printf(_("CD Audio Track %02u"), track); + tuple->genre = g_strdup(cdinfo.genre); + tuple->year = cdinfo.year; + return tuple; }
--- a/src/cdaudio/cddb.c Sun Dec 24 07:08:26 2006 -0800 +++ b/src/cdaudio/cddb.c Thu Dec 28 02:57:42 2006 -0800 @@ -302,9 +302,11 @@ { gint sock; gchar *readstr; - gchar buffer[256], buffer2[BUF2SIZE]; + gchar buffer[256]; /* http line buffer */ + gchar *discid = NULL, *dartist = NULL, *dtitle = NULL, + *dyear = NULL, *dgenre = NULL, *ttitle = NULL; gchar *realstr, *temp; - gint len, command, bufs; + gint len, command; gint num, oldnum; if ((sock = cddb_http_open_connection(server, 80)) == 0) @@ -331,10 +333,8 @@ cddb_log("Read response: %s", buffer); command = 1; - bufs = 0; oldnum = -1; do { -/* fprintf(stderr,"%s\n",buffer); */ realstr = strchr(buffer, '='); if (buffer[0] == '#' || !realstr) continue; @@ -344,58 +344,55 @@ switch (command) { case 1: - if (!strncmp(buffer, "DISCID", 6)) - break; + if (!strncmp(buffer, "DISCID", 6)) { + discid = g_strdup(realstr); + break; + } command++; case 2: if (!strncmp(buffer, "DTITLE", 6)) { - strncpy(buffer2 + bufs, realstr, BUF2SIZE - bufs); - bufs += len; + if((temp = strstr(buffer, " / ")) != NULL) { + dtitle = g_strdup(temp+3); + dartist = g_strndup(realstr, temp - realstr); + } + else { + dtitle = g_strdup(realstr); + } break; } - if (bufs > 0) { - buffer2[BUF2SIZE - 1] = '\0'; - if ((temp = strstr(buffer2, " / ")) != NULL) { - cdda_cdinfo_cd_set(cdinfo, g_strdup(temp + 3), - g_strndup(buffer2, temp - buffer2)); - } - else - cdda_cdinfo_cd_set(cdinfo, g_strdup(buffer2), - g_strdup(buffer2)); - bufs = 0; - } command++; case 3: if (!strncmp(buffer, "DYEAR", 5)) { + dyear = g_strdup(realstr); break; } command++; case 4: if (!strncmp(buffer, "DGENRE", 6)) { + dgenre = g_strdup(realstr); break; } + + // we have obtained all necessary data to set discinfo + cdda_cdinfo_cd_set(cdinfo, dtitle, dartist, discid, dgenre, dyear); + command++; case 5: if (!strncmp(buffer, "TTITLE", 6)) { num = atoi(buffer + 6); if (oldnum < 0 || num == oldnum) { - strncpy(buffer2 + bufs, realstr, BUF2SIZE - bufs); - bufs += len; + ttitle = g_strdup(realstr); } else { - buffer2[BUF2SIZE - 1] = '\0'; - cdda_cdinfo_track_set(cdinfo, oldnum + 1, NULL, - g_strdup(buffer2)); - strncpy(buffer2, realstr, BUF2SIZE); - bufs = len; + cdda_cdinfo_track_set(cdinfo, oldnum + 1, NULL, ttitle); + ttitle = g_strdup(realstr); } oldnum = num; break; } if (oldnum >= 0) - cdda_cdinfo_track_set(cdinfo, oldnum + 1, NULL, - g_strdup(buffer2)); - bufs = 0; + cdda_cdinfo_track_set(cdinfo, oldnum + 1, NULL, ttitle); + oldnum = -1; command++; case 6: @@ -422,7 +419,7 @@ } while (http_read_line(sock, buffer, 256) >= 0); if (oldnum >= 0) - cdda_cdinfo_track_set(cdinfo, oldnum + 1, NULL, g_strdup(buffer2)); + cdda_cdinfo_track_set(cdinfo, oldnum + 1, NULL, ttitle); http_close_connection(sock); return TRUE; @@ -553,16 +550,17 @@ cdinfo_t * cdinfo) { FILE *fd; - gchar buffer[256], buffer2[BUF2SIZE]; + gchar buffer[256]; gchar *realstr, *temp; - gint len, command, bufs; + gchar *discid = NULL, *dartist = NULL, *dtitle = NULL, + *dyear = NULL, *dgenre = NULL, *ttitle = NULL; + gint len, command; gint num, oldnum; if ((fd = fopen(file, "r")) == NULL) return 0; command = 1; - bufs = 0; oldnum = -1; while (fgets(buffer, 256, fd) != NULL) { realstr = strchr(buffer, '='); @@ -576,58 +574,55 @@ switch (command) { case 1: - if (!strncmp(buffer, "DISCID", 6)) + if (!strncmp(buffer, "DISCID", 6)) { + discid = g_strdup(realstr); break; + } command++; case 2: if (!strncmp(buffer, "DTITLE", 6)) { - strncpy(buffer2 + bufs, realstr, BUF2SIZE - bufs); - bufs += len; + if((temp = strstr(buffer, " / ")) != NULL) { + dtitle = g_strdup(temp+3); + dartist = g_strndup(realstr, temp - realstr); + } + else { + dtitle = g_strdup(realstr); + } break; } - if (bufs > 0) { - buffer2[BUF2SIZE - 1] = '\0'; - if ((temp = strstr(buffer2, " / ")) != NULL) { - cdda_cdinfo_cd_set(cdinfo, g_strdup(temp + 3), - g_strndup(buffer2, temp - buffer2)); - } - else - cdda_cdinfo_cd_set(cdinfo, g_strdup(buffer2), - g_strdup(buffer2)); - bufs = 0; - } command++; case 3: if (!strncmp(buffer, "DYEAR", 5)) { + dyear = g_strdup(realstr); break; } command++; case 4: if (!strncmp(buffer, "DGENRE", 6)) { + dgenre = g_strdup(realstr); break; } + + // we have obtained all necessary data to set discinfo + cdda_cdinfo_cd_set(cdinfo, dtitle, dartist, discid, dgenre, dyear); + command++; case 5: if (!strncmp(buffer, "TTITLE", 6)) { num = atoi(buffer + 6); if (oldnum < 0 || num == oldnum) { - strncpy(buffer2 + bufs, realstr, BUF2SIZE - bufs); - bufs += len; + ttitle = g_strdup(realstr); } else { - buffer2[BUF2SIZE - 1] = '\0'; - cdda_cdinfo_track_set(cdinfo, oldnum + 1, NULL, - g_strdup(buffer2)); - strncpy(buffer2, realstr, BUF2SIZE); - bufs = len; + cdda_cdinfo_track_set(cdinfo, oldnum + 1, NULL, ttitle); + ttitle = g_strdup(realstr); } oldnum = num; break; } if (oldnum >= 0) - cdda_cdinfo_track_set(cdinfo, oldnum + 1, NULL, - g_strdup(buffer2)); - bufs = 0; + cdda_cdinfo_track_set(cdinfo, oldnum + 1, NULL, ttitle); + oldnum = -1; command++; case 6: @@ -654,7 +649,7 @@ } if (oldnum >= 0) - cdda_cdinfo_track_set(cdinfo, oldnum + 1, NULL, g_strdup(buffer2)); + cdda_cdinfo_track_set(cdinfo, oldnum + 1, NULL, ttitle); fclose(fd); return (1);
--- a/src/cdaudio/cdinfo.c Sun Dec 24 07:08:26 2006 -0800 +++ b/src/cdaudio/cdinfo.c Thu Dec 28 02:57:42 2006 -0800 @@ -118,18 +118,23 @@ /* - * Function cdda_cdinfo_cd_set (cdinfo, cdname, cdartist) + * Function cdda_cdinfo_cd_set (cdinfo, cdname, cdartist, discid, + * genre, year) * - * Set name and artist for a cd. If CD is a multiartist disc, the - * `artist' should be set to NULL. + * Set name, artist, discid, genre and year for a cd. If CD is a + * multiartist disc, the `artist' should be set to NULL. * */ void -cdda_cdinfo_cd_set(cdinfo_t * cdinfo, gchar * cdname, gchar * cdartist) +cdda_cdinfo_cd_set(cdinfo_t * cdinfo, gchar * cdname, gchar * cdartist, + gchar * discid, gchar * genre, gchar *year) { + cdinfo->is_valid = TRUE; cdinfo->albname = cdname; cdinfo->artname = cdartist; - cdinfo->is_valid = TRUE; + cdinfo->discid = discid ? atoi(discid) : 0; + cdinfo->genre = genre; + cdinfo->year = year ? atoi(year) : 0; } @@ -188,9 +193,20 @@ cdinfo->albname); else bmp_rcfile_write_string(rcfile, sectionname, "Albumname", ""); + if (cdinfo->artname) bmp_rcfile_write_string(rcfile, sectionname, "Artistname", cdinfo->artname); + if (cdinfo->year) { + gchar *yearstr = g_strdup_printf("%4d", cdinfo->year); + bmp_rcfile_write_string(rcfile, sectionname, "Year", yearstr); + g_free(yearstr); + } + + if (cdinfo->genre) + bmp_rcfile_write_string(rcfile, sectionname, "Genre", cdinfo->genre); + + for (i = 1; i <= numtracks; i++) { if (cdinfo->tracks[i].artist) { sprintf(trackstr, "track_artist%d", i); @@ -224,6 +240,7 @@ gchar sectionname[10], trackstr[16]; gint i, numtracks = cddb_discid & 0xff; gboolean track_found; + gchar *yearstr = NULL; sprintf(sectionname, "%08x", cddb_discid); @@ -242,6 +259,15 @@ bmp_rcfile_read_string(rcfile, sectionname, "Artistname", &cdinfo->artname); + bmp_rcfile_read_string(rcfile, sectionname, "Year", &yearstr); + if (yearstr) { + cdinfo->year = atoi(yearstr); + g_free(yearstr); + yearstr = NULL; + } + + bmp_rcfile_read_string(rcfile, sectionname, "Genre", &cdinfo->genre); + for (i = 1; i <= numtracks; i++) { track_found = FALSE; sprintf(trackstr, "track_artist%d", i);
--- a/src/cdaudio/cdinfo.h Sun Dec 24 07:08:26 2006 -0800 +++ b/src/cdaudio/cdinfo.h Thu Dec 28 02:57:42 2006 -0800 @@ -36,8 +36,11 @@ */ typedef struct { gboolean is_valid; + gint discid; gchar *albname; gchar *artname; + gchar *genre; + gint year; trackinfo_t tracks[100]; } cdinfo_t; @@ -45,9 +48,8 @@ cdinfo_t *cdda_cdinfo_new(void); void cdda_cdinfo_delete(cdinfo_t * info); void cdda_cdinfo_track_set(cdinfo_t * cdinfo, gint, gchar *, gchar *); -void cdda_cdinfo_cd_set(cdinfo_t * cdinfo, gchar *, gchar *); -gint cdda_cdinfo_get(cdinfo_t * cdinfo, gint num, gchar **, gchar **, - gchar **); +void cdda_cdinfo_cd_set(cdinfo_t * cdinfo, gchar *, gchar *, gchar *, gchar *, gchar *); +gint cdda_cdinfo_get(cdinfo_t * cdinfo, gint num, gchar **, gchar **, gchar **); gboolean cdda_cdinfo_read_file(guint32 cddb_discid, cdinfo_t * cdinfo); void cdda_cdinfo_write_file(guint32 cddb_discid, cdinfo_t * cdinfo);