From 7c96aa41979b1c1b0b4c582c8ac31b7ff779b737 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Thu, 17 Jul 2008 15:53:01 +0200 Subject: piano: Initial global genre stations support Pandora provides a xml list of genre stations. Read this list and insert its data into our PianoHandle tree if requested. --- libpiano/src/http.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'libpiano/src/http.c') diff --git a/libpiano/src/http.c b/libpiano/src/http.c index c480ff8..c633816 100644 --- a/libpiano/src/http.c +++ b/libpiano/src/http.c @@ -89,3 +89,31 @@ PianoReturn_t PianoHttpPost (CURL *ch, char *url, char *postData, return ret; } + +/* get data + * @param initialized curl handle + * @param call this url + * @param put received data here, memory is allocated by this function + * @return nothing yet + */ +PianoReturn_t PianoHttpGet (CURL *ch, char *url, char **retData) { + /* Let's hope nothing will be bigger than this... */ + char curlRet[PIANO_HTTP_BUFFER_SIZE]; + PianoReturn_t ret; + + curl_easy_setopt (ch, CURLOPT_URL, url); + curl_easy_setopt (ch, CURLOPT_WRITEFUNCTION, PianoCurlRetToVar); + memset (curlRet, 0, sizeof (curlRet)); + curl_easy_setopt (ch, CURLOPT_WRITEDATA, curlRet); + + if (curl_easy_perform (ch) == CURLE_OK) { + ret = PIANO_RET_OK; + *retData = calloc (strlen (curlRet) + 1, sizeof (char)); + strcpy (*retData, curlRet); + } else { + ret = PIANO_RET_NET_ERROR; + *retData = NULL; + } + + return ret; +} -- cgit v1.2.3