diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2002-12-14 21:28:09 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2002-12-14 21:28:09 +0000 |
commit | 71c6d6964a8d802b4c80ffecdc051cfec222084f (patch) | |
tree | 2e63c82273b18a55bb8793a517461061b80b8a8b /usr.bin | |
parent | 1e5413f1683d13be51a4c11d0e0d6e5268d34f54 (diff) |
handle multiline replies from the server.
this actually happens on the 3.2 audio CD.
ok millert@
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/cdio/cddb.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/usr.bin/cdio/cddb.c b/usr.bin/cdio/cddb.c index 9f90acee75a..d7e8e75218d 100644 --- a/usr.bin/cdio/cddb.c +++ b/usr.bin/cdio/cddb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cddb.c,v 1.4 2002/04/18 22:17:04 espie Exp $ */ +/* $OpenBSD: cddb.c,v 1.5 2002/12/14 21:28:08 espie Exp $ */ /* * Copyright (c) 2002 Marc Espie. * @@ -46,7 +46,7 @@ int parse_connect_to(const char *, const char *); char * get_line(FILE *); char * get_answer(FILE *); void verify_track_names(char **, int, struct cd_toc_entry *); -char * safe_copy(const char *); +void safe_copy(char **, const char *); unsigned long cddb_sum(unsigned long v) @@ -99,11 +99,21 @@ send_query(FILE *f, int n, struct cd_toc_entry *e) #define MAXSIZE 256 char copy_buffer[MAXSIZE]; -char * -safe_copy(const char *title) +void +safe_copy(char **p, const char *title) { strnvis(copy_buffer, title, MAXSIZE-1, VIS_TAB|VIS_NL); - return strdup(copy_buffer); + if (*p == NULL) + *p = strdup(copy_buffer); + else { + char *n = malloc(strlen(*p) + strlen(copy_buffer) + 1); + if (n == NULL) + return; + strcpy(n, *p); + strcat(n, copy_buffer); + free(*p); + *p = n; + } } int @@ -342,7 +352,7 @@ cddb(const char *host_port, int n, struct cd_toc_entry *e, char *arg) continue; if (k >= n) continue; - result[k] = safe_copy(end); + safe_copy(&result[k], end); } fprintf(cout, "QUIT\r\n"); verify_track_names(result, n, e); |