Lines Matching refs:pS3Int

210 static char* rtS3CreateSignature(PRTS3INTERNAL pS3Int, const char* pszAction, const char* pszBucket, const char* pszKey,
219 HMAC(EVP_sha1(), pS3Int->pszSecretKey, (int)strlen(pS3Int->pszSecretKey),
232 static char* rtS3CreateAuthHeader(PRTS3INTERNAL pS3Int, const char* pszAction, const char* pszBucket, const char* pszKey,
237 char *pszSigBase64Enc = rtS3CreateSignature(pS3Int, pszAction, pszBucket, pszKey, papszHeadEnts, cHeadEnts);
240 pS3Int->pszAccessKey,
246 static int rtS3Perform(PRTS3INTERNAL pS3Int)
249 CURLcode code = curl_easy_perform(pS3Int->pCurl);
252 curl_easy_getinfo(pS3Int->pCurl, CURLINFO_RESPONSE_CODE, &pS3Int->lLastResp);
253 switch (pS3Int->lLastResp)
324 PRTS3INTERNAL pS3Int = (PRTS3INTERNAL)pvUser;
325 if (pS3Int->pfnProgressCallback)
329 rc = pS3Int->pfnProgressCallback((unsigned)(100.0/dDlTotal*dDlNow), pS3Int->pvUser);
331 rc = pS3Int->pfnProgressCallback((unsigned)(100.0/dUlTotal*dUlNow), pS3Int->pvUser);
339 static void rtS3ReinitCurl(PRTS3INTERNAL pS3Int)
341 if (pS3Int &&
342 pS3Int->pCurl)
345 curl_easy_reset(pS3Int->pCurl);
347 curl_easy_setopt(pS3Int->pCurl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
349 if (pS3Int->pszUserAgent)
350 curl_easy_setopt(pS3Int->pCurl, CURLOPT_USERAGENT, pS3Int->pszUserAgent);
352 if (pS3Int->pfnProgressCallback)
355 curl_easy_setopt(pS3Int->pCurl, CURLOPT_NOPROGRESS, 0);
357 curl_easy_setopt(pS3Int->pCurl, CURLOPT_PROGRESSFUNCTION, rtS3ProgressCallback);
358 curl_easy_setopt(pS3Int->pCurl, CURLOPT_PROGRESSDATA, pS3Int);
362 curl_easy_setopt(pS3Int->pCurl, CURLOPT_WRITEFUNCTION, rtS3WriteNothingCallback);
364 // curl_easy_setopt(pS3Int->pCurl, CURLOPT_VERBOSE, 1);
520 PRTS3INTERNAL pS3Int = (PRTS3INTERNAL)RTMemAllocZ(sizeof(RTS3INTERNAL));
521 if (pS3Int == NULL)
524 pS3Int->u32Magic = RTS3_MAGIC;
525 pS3Int->pCurl = pCurl;
526 pS3Int->pszAccessKey = RTStrDup(pszAccessKey);
527 pS3Int->pszSecretKey = RTStrDup(pszSecretKey);
528 pS3Int->pszBaseUrl = RTStrDup(pszBaseUrl);
530 pS3Int->pszUserAgent = RTStrDup(pszUserAgent);
532 *ppS3 = (RTS3)pS3Int;
542 PRTS3INTERNAL pS3Int = hS3;
543 RTS3_VALID_RETURN_VOID(pS3Int);
545 curl_easy_cleanup(pS3Int->pCurl);
547 pS3Int->u32Magic = RTS3_MAGIC_DEAD;
549 if (pS3Int->pszUserAgent)
550 RTStrFree(pS3Int->pszUserAgent);
551 RTStrFree(pS3Int->pszBaseUrl);
552 RTStrFree(pS3Int->pszSecretKey);
553 RTStrFree(pS3Int->pszAccessKey);
555 RTMemFree(pS3Int);
562 PRTS3INTERNAL pS3Int = hS3;
563 RTS3_VALID_RETURN_VOID(pS3Int);
565 pS3Int->pfnProgressCallback = pfnProgressCallback;
566 pS3Int->pvUser = pvUser;
571 PRTS3INTERNAL pS3Int = hS3;
572 RTS3_VALID_RETURN(pS3Int);
578 rtS3ReinitCurl(pS3Int);
580 curl_easy_setopt(pS3Int->pCurl, CURLOPT_URL, pS3Int->pszBaseUrl);
585 rtS3HostHeader("", pS3Int->pszBaseUrl), /* Host entry */
590 apszHead[RT_ELEMENTS(apszHead)-1] = rtS3CreateAuthHeader(pS3Int, "GET", "", "", apszHead, RT_ELEMENTS(apszHead));
598 curl_easy_setopt(pS3Int->pCurl, CURLOPT_HTTPHEADER, pHeaders);
602 curl_easy_setopt(pS3Int->pCurl, CURLOPT_WRITEFUNCTION, rtS3WriteMemoryCallback);
603 curl_easy_setopt(pS3Int->pCurl, CURLOPT_WRITEDATA, (void *)&chunk);
605 int rc = rtS3Perform(pS3Int);
651 PRTS3INTERNAL pS3Int = hS3;
652 RTS3_VALID_RETURN(pS3Int);
655 rtS3ReinitCurl(pS3Int);
657 char* pszUrl = rtS3Host(pszBucketName, "", pS3Int->pszBaseUrl);
658 curl_easy_setopt(pS3Int->pCurl, CURLOPT_URL, pszUrl);
665 rtS3HostHeader(pszBucketName, pS3Int->pszBaseUrl), /* Host entry */
670 apszHead[RT_ELEMENTS(apszHead)-1] = rtS3CreateAuthHeader(pS3Int, "PUT", pszBucketName, "", apszHead, RT_ELEMENTS(apszHead));
678 curl_easy_setopt(pS3Int->pCurl, CURLOPT_HTTPHEADER, pHeaders);
681 curl_easy_setopt(pS3Int->pCurl, CURLOPT_PUT, 1);
682 curl_easy_setopt(pS3Int->pCurl, CURLOPT_UPLOAD, 1);
685 curl_easy_setopt(pS3Int->pCurl, CURLOPT_INFILESIZE_LARGE, 0);
688 int rc = rtS3Perform(pS3Int);
692 if (pS3Int->lLastResp == 409)
706 PRTS3INTERNAL pS3Int = hS3;
707 RTS3_VALID_RETURN(pS3Int);
710 rtS3ReinitCurl(pS3Int);
712 char* pszUrl = rtS3Host(pszBucketName, "", pS3Int->pszBaseUrl);
713 curl_easy_setopt(pS3Int->pCurl, CURLOPT_URL, pszUrl);
719 rtS3HostHeader(pszBucketName, pS3Int->pszBaseUrl), /* Host entry */
724 apszHead[RT_ELEMENTS(apszHead)-1] = rtS3CreateAuthHeader(pS3Int, "DELETE", pszBucketName, "", apszHead, RT_ELEMENTS(apszHead));
732 curl_easy_setopt(pS3Int->pCurl, CURLOPT_HTTPHEADER, pHeaders);
735 curl_easy_setopt(pS3Int->pCurl, CURLOPT_CUSTOMREQUEST, "DELETE");
738 int rc = rtS3Perform(pS3Int);
742 if (pS3Int->lLastResp == 409)
756 PRTS3INTERNAL pS3Int = hS3;
757 RTS3_VALID_RETURN(pS3Int);
762 rtS3ReinitCurl(pS3Int);
764 char* pszUrl = rtS3Host(pszBucketName, "", pS3Int->pszBaseUrl);
765 curl_easy_setopt(pS3Int->pCurl, CURLOPT_URL, pszUrl);
771 rtS3HostHeader(pszBucketName, pS3Int->pszBaseUrl), /* Host entry */
776 apszHead[RT_ELEMENTS(apszHead)-1] = rtS3CreateAuthHeader(pS3Int, "GET", pszBucketName, "", apszHead, RT_ELEMENTS(apszHead));
784 curl_easy_setopt(pS3Int->pCurl, CURLOPT_HTTPHEADER, pHeaders);
788 curl_easy_setopt(pS3Int->pCurl, CURLOPT_WRITEFUNCTION, rtS3WriteMemoryCallback);
789 curl_easy_setopt(pS3Int->pCurl, CURLOPT_WRITEDATA, (void *)&chunk);
792 int rc = rtS3Perform(pS3Int);
838 PRTS3INTERNAL pS3Int = hS3;
839 RTS3_VALID_RETURN(pS3Int);
842 rtS3ReinitCurl(pS3Int);
844 char* pszUrl = rtS3Host(pszBucketName, pszKeyName, pS3Int->pszBaseUrl);
845 curl_easy_setopt(pS3Int->pCurl, CURLOPT_URL, pszUrl);
851 rtS3HostHeader(pszBucketName, pS3Int->pszBaseUrl), /* Host entry */
856 apszHead[RT_ELEMENTS(apszHead)-1] = rtS3CreateAuthHeader(pS3Int, "DELETE", pszBucketName, pszKeyName, apszHead, RT_ELEMENTS(apszHead));
864 curl_easy_setopt(pS3Int->pCurl, CURLOPT_HTTPHEADER, pHeaders);
867 curl_easy_setopt(pS3Int->pCurl, CURLOPT_CUSTOMREQUEST, "DELETE");
870 int rc = rtS3Perform(pS3Int);
882 PRTS3INTERNAL pS3Int = hS3;
883 RTS3_VALID_RETURN(pS3Int);
886 rtS3ReinitCurl(pS3Int);
894 char* pszUrl = rtS3Host(pszBucketName, pszKeyName, pS3Int->pszBaseUrl);
895 curl_easy_setopt(pS3Int->pCurl, CURLOPT_URL, pszUrl);
901 rtS3HostHeader(pszBucketName, pS3Int->pszBaseUrl), /* Host entry */
906 apszHead[RT_ELEMENTS(apszHead)-1] = rtS3CreateAuthHeader(pS3Int, "GET", pszBucketName, pszKeyName, apszHead, RT_ELEMENTS(apszHead));
914 curl_easy_setopt(pS3Int->pCurl, CURLOPT_HTTPHEADER, pHeaders);
917 curl_easy_setopt(pS3Int->pCurl, CURLOPT_WRITEFUNCTION, rtS3WriteFileCallback);
918 curl_easy_setopt(pS3Int->pCurl, CURLOPT_WRITEDATA, &hFile);
921 rc = rtS3Perform(pS3Int);
940 PRTS3INTERNAL pS3Int = hS3;
941 RTS3_VALID_RETURN(pS3Int);
944 rtS3ReinitCurl(pS3Int);
960 char* pszUrl = rtS3Host(pszBucketName, pszKeyName, pS3Int->pszBaseUrl);
961 curl_easy_setopt(pS3Int->pCurl, CURLOPT_URL, pszUrl);
974 rtS3HostHeader(pszBucketName, pS3Int->pszBaseUrl), /* Host entry */
979 apszHead[RT_ELEMENTS(apszHead)-1] = rtS3CreateAuthHeader(pS3Int, "PUT", pszBucketName, pszKeyName, apszHead, RT_ELEMENTS(apszHead));
987 curl_easy_setopt(pS3Int->pCurl, CURLOPT_HTTPHEADER, pHeaders);
990 curl_easy_setopt(pS3Int->pCurl, CURLOPT_PUT, 1);
991 curl_easy_setopt(pS3Int->pCurl, CURLOPT_UPLOAD, 1);
994 curl_easy_setopt(pS3Int->pCurl, CURLOPT_INFILESIZE_LARGE, cbFileSize);
997 curl_easy_setopt(pS3Int->pCurl, CURLOPT_READFUNCTION, rtS3ReadFileCallback);
998 curl_easy_setopt(pS3Int->pCurl, CURLOPT_READDATA, &hFile);
999 curl_easy_setopt(pS3Int->pCurl, CURLOPT_SSLVERSION, (long)CURL_SSLVERSION_TLSv1);
1002 rc = rtS3Perform(pS3Int);