summaryrefslogtreecommitdiff
path: root/libpiano/src/http.c
diff options
context:
space:
mode:
authorLars-Dominik Braun <PromyLOPh@gmail.com>2008-07-07 20:48:10 +0200
committerLars-Dominik Braun <PromyLOPh@gmail.com>2008-07-07 20:48:10 +0200
commit51edb36f6bd9d119c12ef893ecc1d3541f80b00a (patch)
treefca5a33058212558b2bfe566ad4e1f629d378d28 /libpiano/src/http.c
parent701177ef5b4005d8f03c7f9f47081bb4e7c46517 (diff)
downloadpianobar-51edb36f6bd9d119c12ef893ecc1d3541f80b00a.tar.gz
pianobar-51edb36f6bd9d119c12ef893ecc1d3541f80b00a.tar.bz2
pianobar-51edb36f6bd9d119c12ef893ecc1d3541f80b00a.zip
piano: Handle network errors
Diffstat (limited to 'libpiano/src/http.c')
-rw-r--r--libpiano/src/http.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/libpiano/src/http.c b/libpiano/src/http.c
index ee63fef..52b2f2b 100644
--- a/libpiano/src/http.c
+++ b/libpiano/src/http.c
@@ -58,10 +58,12 @@ size_t PianoCurlRetToVar (void *ptr, size_t size, size_t nmemb, void *stream) {
* @param put received data here, memory is allocated by this function
* @return nothing yet
*/
-void PianoHttpPost (CURL *ch, char *url, char *postData, char **retData) {
+PianoReturn_t PianoHttpPost (CURL *ch, char *url, char *postData,
+ char **retData) {
struct curl_slist *headers = NULL;
/* Let's hope nothing will be bigger than this... */
char curlRet[PIANO_HTTP_BUFFER_SIZE];
+ PianoReturn_t ret;
headers = curl_slist_append (headers, "Content-Type: text/xml");
@@ -74,10 +76,16 @@ void PianoHttpPost (CURL *ch, char *url, char *postData, char **retData) {
memset (curlRet, 0, sizeof (curlRet));
curl_easy_setopt (ch, CURLOPT_WRITEDATA, curlRet);
- curl_easy_perform (ch);
+ 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;
+ }
curl_slist_free_all (headers);
- *retData = calloc (strlen (curlRet) + 1, sizeof (char));
- strcpy (*retData, curlRet);
+ return ret;
}