int16_t verifyProwlAPIKey(const char* apikey) { int16_t result = -1; char url[128]; HTTPResponse *response = NULL; CURL *curl_session = NULL; if(apikey) { snprintf(url, 128, "%s%s?apikey=%s", PROWL_URL, PROWL_VERIFY, apikey); response = getHTTPData(url, NULL, &curl_session); if(response) { if(response->responseCode == 200) { dbg_printf(P_INFO, "Prowl API key '%s' is valid", apikey); result = 1; } else { dbg_printf(P_ERROR, "Error: Prowl API key '%s' is invalid (%d)!", apikey, response->responseCode); result = -response->responseCode; } HTTPResponse_free(response); } closeCURLSession(curl_session); } return result; }
PRIVATE HTTPResponse* downloadTorrent(CURL* curl_session, const char* url) { HTTPResponse * torrent = NULL; dbg_printf(P_INFO2, "[downloadTorrent] url=%s, curl_session=%p", url, (void*)curl_session); torrent = getHTTPData(url, NULL, &curl_session); if(torrent && torrent->responseCode != 200) { switch(torrent->responseCode) { case 401: dbg_printf(P_ERROR, "Error downloading torrent (HTTP error %d: Bad authentication)", torrent->responseCode); break; case 403: dbg_printf(P_ERROR, "Error downloading torrent (HTTP error %d: Forbidden)", torrent->responseCode); break; default: dbg_printf(P_ERROR, "Error downloading torrent (HTTP error %d)", torrent->responseCode); } HTTPResponse_free(torrent); torrent = NULL; } return torrent; }
PRIVATE HTTPResponse* getRSSFeed(const rss_feed* feed, CURL **session) { return getHTTPData(feed->url, feed->cookies, session); }