duckstation

duckstation, but archived from the revision just before upstream changed it to a proprietary software project, this version is the libre one
git clone https://git.neptards.moe/u3shit/duckstation.git
Log | Files | Refs | README | LICENSE

http_downloader_curl.h (888B)


      1 // SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com>
      2 // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
      3 
      4 #pragma once
      5 #include "http_downloader.h"
      6 
      7 #include <atomic>
      8 #include <curl/curl.h>
      9 #include <memory>
     10 #include <mutex>
     11 
     12 class HTTPDownloaderCurl final : public HTTPDownloader
     13 {
     14 public:
     15   HTTPDownloaderCurl();
     16   ~HTTPDownloaderCurl() override;
     17 
     18   bool Initialize(std::string user_agent);
     19 
     20 protected:
     21   Request* InternalCreateRequest() override;
     22   void InternalPollRequests() override;
     23   bool StartRequest(HTTPDownloader::Request* request) override;
     24   void CloseRequest(HTTPDownloader::Request* request) override;
     25 
     26 private:
     27   struct Request : HTTPDownloader::Request
     28   {
     29     CURL* handle = nullptr;
     30   };
     31 
     32   static size_t WriteCallback(char* ptr, size_t size, size_t nmemb, void* userdata);
     33 
     34   CURLM* m_multi_handle = nullptr;
     35   std::string m_user_agent;
     36 };