コード例 #1
0
ファイル: prowl.c プロジェクト: cjo9900/Automatic
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;
}
コード例 #2
0
ファイル: automatic.c プロジェクト: 1100101/Automatic
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;
}
コード例 #3
0
ファイル: trailermatic.c プロジェクト: 1100101/trailermatic
PRIVATE HTTPResponse* getRSSFeed(const rss_feed* feed, CURL **session) {
  return getHTTPData(feed->url, feed->cookies, session);
}