// Jackson Coxson #ifndef IDEVICE_CPP #define IDEVICE_CPP #include #include #include #include #if defined(_WIN32) && !defined(__MINGW32__) // MSVC doesn't have BSD u_int* types using u_int8_t = std::uint8_t; using u_int16_t = std::uint16_t; using u_int32_t = std::uint32_t; using u_int64_t = std::uint64_t; #endif namespace IdeviceFFI { // Generic “bind a free function” deleter template struct FnDeleter { void operator()(T* p) const noexcept { if (p) FreeFn(p); } }; using IdevicePtr = std::unique_ptr>; class Idevice { public: static std::optional create(IdeviceSocketHandle* socket, const std::string& label, FfiError& err); static std::optional create_tcp(const sockaddr* addr, socklen_t addr_len, const std::string& label, FfiError& err); // Methods std::optional get_type(FfiError& err) const; bool rsd_checkin(FfiError& err); bool start_session(const PairingFile& pairing_file, FfiError& err); // Ownership/RAII ~Idevice() noexcept = default; Idevice(Idevice&&) noexcept = default; Idevice& operator=(Idevice&&) noexcept = default; Idevice(const Idevice&) = delete; Idevice& operator=(const Idevice&) = delete; static Idevice adopt(IdeviceHandle* h) noexcept { return Idevice(h); } // Accessor IdeviceHandle* raw() const noexcept { return handle_.get(); } IdeviceHandle* release() noexcept { return handle_.release(); } private: explicit Idevice(IdeviceHandle* h) noexcept : handle_(h) {} IdevicePtr handle_{}; }; } // namespace IdeviceFFI #endif