when a track has a long title, it comes in several parts. this patch allows acd to display such long titles, rather than the last section of the name only. Reference: /n/sources/patch/applied/acdlongnames Date: Wed Aug 25 18:57:03 CES 2004 --- /acme/bin/source/acd/cddb.c Wed Aug 25 18:57:03 2004 +++ /acme/bin/source/acd/cddb.c Wed Aug 25 18:57:03 2004 @@ -35,6 +35,21 @@ return ((n & 0xFF) << 24 | (tmp << 8) | t->ntrack); } +static void +append(char **d, char *s) +{ + char *r; + if (*d == nil) + *d = estrdup(s); + else { + r = emalloc(strlen(*d) + strlen(s) + 1); + strcpy(r, *d); + strcat(r, s); + free(*d); + *d = r; + } +} + static int cddbfilltoc(Toc *t) { @@ -46,6 +61,8 @@ char *f[10]; int nf; char *id, *categ; + char gottrack[MTRACK]; + int gottitle; fd = dial("tcp!freedb.freedb.org!888", 0, 0, 0); if(fd < 0) { @@ -125,6 +142,9 @@ /* fetch results for this cd */ fprint(fd, "cddb read %s %s\r\n", categ, id); + + memset(gottrack, 0, sizeof(gottrack)); + gottitle = 0; do { if((p = Brdline(&bin, '\n')) == nil) goto died; @@ -132,9 +152,13 @@ while(isspace(*q)) *q-- = 0; DPRINT(2, "cddb %s\n", p); - if(strncmp(p, "DTITLE=", 7) == 0) - t->title = estrdup(p+7); - else if(strncmp(p, "TTITLE", 6) == 0 && isdigit(p[6])) { + if(strncmp(p, "DTITLE=", 7) == 0) { + if (gottitle) + append(&t->title, p + 7); + else + t->title = estrdup(p+7); + gottitle = 1; + } else if(strncmp(p, "TTITLE", 6) == 0 && isdigit(p[6])) { i = atoi(p+6); if(i < t->ntrack) { p += 6; @@ -143,7 +167,11 @@ if(*p == '=') p++; - t->track[i].title = estrdup(p); + if (gottrack[i]) + append(&t->track[i].title, p); + else + t->track[i].title = estrdup(p); + gottrack[i] = 1; } } } while(*p != '.'); @@ -154,7 +182,6 @@ return 0; } - void cddbproc(void *v)