diff --git a/ffigen.yaml b/ffigen.yaml new file mode 100644 index 0000000..f0c74ec --- /dev/null +++ b/ffigen.yaml @@ -0,0 +1,16 @@ +# Run with `flutter pub run ffigen --config ffigen.yaml`. +name: TorrentLibrary +description: Bindings to `lib/ffi/libmtorrentserver.h`. +output: 'lib/ffi/generated_bindings.dart' +headers: + entry-points: + - 'lib/ffi/libmtorrentserver.h' +preamble: | + // ignore_for_file: always_specify_types + // ignore_for_file: camel_case_types + // ignore_for_file: non_constant_identifier_names + // ignore_for_file: unused_field + // ignore_for_file: unused_element +comments: + style: any + length: full diff --git a/lib/ffi/generated_bindings.dart b/lib/ffi/generated_bindings.dart new file mode 100644 index 0000000..debcf28 --- /dev/null +++ b/lib/ffi/generated_bindings.dart @@ -0,0 +1,1030 @@ +// ignore_for_file: always_specify_types +// ignore_for_file: camel_case_types +// ignore_for_file: non_constant_identifier_names +// ignore_for_file: unused_field +// ignore_for_file: unused_element + +// AUTO GENERATED FILE, DO NOT EDIT. +// +// Generated by `package:ffigen`. +// ignore_for_file: type=lint +import 'dart:ffi' as ffi; + +/// Bindings to `lib/ffi/libmtorrentserver.h`. +class TorrentLibrary { + /// Holds the symbol lookup function. + final ffi.Pointer Function(String symbolName) + _lookup; + + /// The symbols are looked up in [dynamicLibrary]. + TorrentLibrary(ffi.DynamicLibrary dynamicLibrary) + : _lookup = dynamicLibrary.lookup; + + /// The symbols are looked up with [lookup]. + TorrentLibrary.fromLookup( + ffi.Pointer Function(String symbolName) + lookup) + : _lookup = lookup; + + void __va_start( + ffi.Pointer arg0, + ) { + return ___va_start( + arg0, + ); + } + + late final ___va_startPtr = + _lookup)>>( + '__va_start'); + late final ___va_start = + ___va_startPtr.asFunction)>(); + + void __security_init_cookie() { + return ___security_init_cookie(); + } + + late final ___security_init_cookiePtr = + _lookup>( + '__security_init_cookie'); + late final ___security_init_cookie = + ___security_init_cookiePtr.asFunction(); + + void __security_check_cookie( + int _StackCookie, + ) { + return ___security_check_cookie( + _StackCookie, + ); + } + + late final ___security_check_cookiePtr = + _lookup>( + '__security_check_cookie'); + late final ___security_check_cookie = + ___security_check_cookiePtr.asFunction(); + + void __report_gsfailure( + int _StackCookie, + ) { + return ___report_gsfailure( + _StackCookie, + ); + } + + late final ___report_gsfailurePtr = + _lookup>( + '__report_gsfailure'); + late final ___report_gsfailure = + ___report_gsfailurePtr.asFunction(); + + late final ffi.Pointer ___security_cookie = + _lookup('__security_cookie'); + + int get __security_cookie => ___security_cookie.value; + + set __security_cookie(int value) => ___security_cookie.value = value; + + void _invalid_parameter_noinfo() { + return __invalid_parameter_noinfo(); + } + + late final __invalid_parameter_noinfoPtr = + _lookup>( + '_invalid_parameter_noinfo'); + late final __invalid_parameter_noinfo = + __invalid_parameter_noinfoPtr.asFunction(); + + void _invalid_parameter_noinfo_noreturn() { + return __invalid_parameter_noinfo_noreturn(); + } + + late final __invalid_parameter_noinfo_noreturnPtr = + _lookup>( + '_invalid_parameter_noinfo_noreturn'); + late final __invalid_parameter_noinfo_noreturn = + __invalid_parameter_noinfo_noreturnPtr.asFunction(); + + void _invoke_watson( + ffi.Pointer _Expression, + ffi.Pointer _FunctionName, + ffi.Pointer _FileName, + int _LineNo, + int _Reserved, + ) { + return __invoke_watson( + _Expression, + _FunctionName, + _FileName, + _LineNo, + _Reserved, + ); + } + + late final __invoke_watsonPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.UnsignedInt, + ffi.UintPtr)>>('_invoke_watson'); + late final __invoke_watson = __invoke_watsonPtr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, int, int)>(); + + ffi.Pointer _errno() { + return __errno(); + } + + late final __errnoPtr = + _lookup Function()>>('_errno'); + late final __errno = __errnoPtr.asFunction Function()>(); + + int _set_errno( + int _Value, + ) { + return __set_errno( + _Value, + ); + } + + late final __set_errnoPtr = + _lookup>('_set_errno'); + late final __set_errno = __set_errnoPtr.asFunction(); + + int _get_errno( + ffi.Pointer _Value, + ) { + return __get_errno( + _Value, + ); + } + + late final __get_errnoPtr = + _lookup)>>( + '_get_errno'); + late final __get_errno = + __get_errnoPtr.asFunction)>(); + + int __threadid() { + return ___threadid(); + } + + late final ___threadidPtr = + _lookup>('__threadid'); + late final ___threadid = ___threadidPtr.asFunction(); + + int __threadhandle() { + return ___threadhandle(); + } + + late final ___threadhandlePtr = + _lookup>('__threadhandle'); + late final ___threadhandle = ___threadhandlePtr.asFunction(); + + double cabs( + _Dcomplex _Z, + ) { + return _cabs( + _Z, + ); + } + + late final _cabsPtr = + _lookup>('cabs'); + late final _cabs = _cabsPtr.asFunction(); + + _Dcomplex cacos( + _Dcomplex _Z, + ) { + return _cacos( + _Z, + ); + } + + late final _cacosPtr = + _lookup>('cacos'); + late final _cacos = _cacosPtr.asFunction<_Dcomplex Function(_Dcomplex)>(); + + _Dcomplex cacosh( + _Dcomplex _Z, + ) { + return _cacosh( + _Z, + ); + } + + late final _cacoshPtr = + _lookup>('cacosh'); + late final _cacosh = _cacoshPtr.asFunction<_Dcomplex Function(_Dcomplex)>(); + + double carg( + _Dcomplex _Z, + ) { + return _carg( + _Z, + ); + } + + late final _cargPtr = + _lookup>('carg'); + late final _carg = _cargPtr.asFunction(); + + _Dcomplex casin( + _Dcomplex _Z, + ) { + return _casin( + _Z, + ); + } + + late final _casinPtr = + _lookup>('casin'); + late final _casin = _casinPtr.asFunction<_Dcomplex Function(_Dcomplex)>(); + + _Dcomplex casinh( + _Dcomplex _Z, + ) { + return _casinh( + _Z, + ); + } + + late final _casinhPtr = + _lookup>('casinh'); + late final _casinh = _casinhPtr.asFunction<_Dcomplex Function(_Dcomplex)>(); + + _Dcomplex catan( + _Dcomplex _Z, + ) { + return _catan( + _Z, + ); + } + + late final _catanPtr = + _lookup>('catan'); + late final _catan = _catanPtr.asFunction<_Dcomplex Function(_Dcomplex)>(); + + _Dcomplex catanh( + _Dcomplex _Z, + ) { + return _catanh( + _Z, + ); + } + + late final _catanhPtr = + _lookup>('catanh'); + late final _catanh = _catanhPtr.asFunction<_Dcomplex Function(_Dcomplex)>(); + + _Dcomplex ccos( + _Dcomplex _Z, + ) { + return _ccos( + _Z, + ); + } + + late final _ccosPtr = + _lookup>('ccos'); + late final _ccos = _ccosPtr.asFunction<_Dcomplex Function(_Dcomplex)>(); + + _Dcomplex ccosh( + _Dcomplex _Z, + ) { + return _ccosh( + _Z, + ); + } + + late final _ccoshPtr = + _lookup>('ccosh'); + late final _ccosh = _ccoshPtr.asFunction<_Dcomplex Function(_Dcomplex)>(); + + _Dcomplex cexp( + _Dcomplex _Z, + ) { + return _cexp( + _Z, + ); + } + + late final _cexpPtr = + _lookup>('cexp'); + late final _cexp = _cexpPtr.asFunction<_Dcomplex Function(_Dcomplex)>(); + + double cimag( + _Dcomplex _Z, + ) { + return _cimag( + _Z, + ); + } + + late final _cimagPtr = + _lookup>('cimag'); + late final _cimag = _cimagPtr.asFunction(); + + _Dcomplex clog( + _Dcomplex _Z, + ) { + return _clog( + _Z, + ); + } + + late final _clogPtr = + _lookup>('clog'); + late final _clog = _clogPtr.asFunction<_Dcomplex Function(_Dcomplex)>(); + + _Dcomplex clog10( + _Dcomplex _Z, + ) { + return _clog10( + _Z, + ); + } + + late final _clog10Ptr = + _lookup>('clog10'); + late final _clog10 = _clog10Ptr.asFunction<_Dcomplex Function(_Dcomplex)>(); + + _Dcomplex conj( + _Dcomplex _Z, + ) { + return _conj( + _Z, + ); + } + + late final _conjPtr = + _lookup>('conj'); + late final _conj = _conjPtr.asFunction<_Dcomplex Function(_Dcomplex)>(); + + _Dcomplex cpow( + _Dcomplex _X, + _Dcomplex _Y, + ) { + return _cpow( + _X, + _Y, + ); + } + + late final _cpowPtr = + _lookup>( + 'cpow'); + late final _cpow = + _cpowPtr.asFunction<_Dcomplex Function(_Dcomplex, _Dcomplex)>(); + + _Dcomplex cproj( + _Dcomplex _Z, + ) { + return _cproj( + _Z, + ); + } + + late final _cprojPtr = + _lookup>('cproj'); + late final _cproj = _cprojPtr.asFunction<_Dcomplex Function(_Dcomplex)>(); + + double creal( + _Dcomplex _Z, + ) { + return _creal( + _Z, + ); + } + + late final _crealPtr = + _lookup>('creal'); + late final _creal = _crealPtr.asFunction(); + + _Dcomplex csin( + _Dcomplex _Z, + ) { + return _csin( + _Z, + ); + } + + late final _csinPtr = + _lookup>('csin'); + late final _csin = _csinPtr.asFunction<_Dcomplex Function(_Dcomplex)>(); + + _Dcomplex csinh( + _Dcomplex _Z, + ) { + return _csinh( + _Z, + ); + } + + late final _csinhPtr = + _lookup>('csinh'); + late final _csinh = _csinhPtr.asFunction<_Dcomplex Function(_Dcomplex)>(); + + _Dcomplex csqrt( + _Dcomplex _Z, + ) { + return _csqrt( + _Z, + ); + } + + late final _csqrtPtr = + _lookup>('csqrt'); + late final _csqrt = _csqrtPtr.asFunction<_Dcomplex Function(_Dcomplex)>(); + + _Dcomplex ctan( + _Dcomplex _Z, + ) { + return _ctan( + _Z, + ); + } + + late final _ctanPtr = + _lookup>('ctan'); + late final _ctan = _ctanPtr.asFunction<_Dcomplex Function(_Dcomplex)>(); + + _Dcomplex ctanh( + _Dcomplex _Z, + ) { + return _ctanh( + _Z, + ); + } + + late final _ctanhPtr = + _lookup>('ctanh'); + late final _ctanh = _ctanhPtr.asFunction<_Dcomplex Function(_Dcomplex)>(); + + double norm( + _Dcomplex _Z, + ) { + return _norm( + _Z, + ); + } + + late final _normPtr = + _lookup>('norm'); + late final _norm = _normPtr.asFunction(); + + double cabsf( + _Fcomplex _Z, + ) { + return _cabsf( + _Z, + ); + } + + late final _cabsfPtr = + _lookup>('cabsf'); + late final _cabsf = _cabsfPtr.asFunction(); + + _Fcomplex cacosf( + _Fcomplex _Z, + ) { + return _cacosf( + _Z, + ); + } + + late final _cacosfPtr = + _lookup>('cacosf'); + late final _cacosf = _cacosfPtr.asFunction<_Fcomplex Function(_Fcomplex)>(); + + _Fcomplex cacoshf( + _Fcomplex _Z, + ) { + return _cacoshf( + _Z, + ); + } + + late final _cacoshfPtr = + _lookup>('cacoshf'); + late final _cacoshf = _cacoshfPtr.asFunction<_Fcomplex Function(_Fcomplex)>(); + + double cargf( + _Fcomplex _Z, + ) { + return _cargf( + _Z, + ); + } + + late final _cargfPtr = + _lookup>('cargf'); + late final _cargf = _cargfPtr.asFunction(); + + _Fcomplex casinf( + _Fcomplex _Z, + ) { + return _casinf( + _Z, + ); + } + + late final _casinfPtr = + _lookup>('casinf'); + late final _casinf = _casinfPtr.asFunction<_Fcomplex Function(_Fcomplex)>(); + + _Fcomplex casinhf( + _Fcomplex _Z, + ) { + return _casinhf( + _Z, + ); + } + + late final _casinhfPtr = + _lookup>('casinhf'); + late final _casinhf = _casinhfPtr.asFunction<_Fcomplex Function(_Fcomplex)>(); + + _Fcomplex catanf( + _Fcomplex _Z, + ) { + return _catanf( + _Z, + ); + } + + late final _catanfPtr = + _lookup>('catanf'); + late final _catanf = _catanfPtr.asFunction<_Fcomplex Function(_Fcomplex)>(); + + _Fcomplex catanhf( + _Fcomplex _Z, + ) { + return _catanhf( + _Z, + ); + } + + late final _catanhfPtr = + _lookup>('catanhf'); + late final _catanhf = _catanhfPtr.asFunction<_Fcomplex Function(_Fcomplex)>(); + + _Fcomplex ccosf( + _Fcomplex _Z, + ) { + return _ccosf( + _Z, + ); + } + + late final _ccosfPtr = + _lookup>('ccosf'); + late final _ccosf = _ccosfPtr.asFunction<_Fcomplex Function(_Fcomplex)>(); + + _Fcomplex ccoshf( + _Fcomplex _Z, + ) { + return _ccoshf( + _Z, + ); + } + + late final _ccoshfPtr = + _lookup>('ccoshf'); + late final _ccoshf = _ccoshfPtr.asFunction<_Fcomplex Function(_Fcomplex)>(); + + _Fcomplex cexpf( + _Fcomplex _Z, + ) { + return _cexpf( + _Z, + ); + } + + late final _cexpfPtr = + _lookup>('cexpf'); + late final _cexpf = _cexpfPtr.asFunction<_Fcomplex Function(_Fcomplex)>(); + + double cimagf( + _Fcomplex _Z, + ) { + return _cimagf( + _Z, + ); + } + + late final _cimagfPtr = + _lookup>('cimagf'); + late final _cimagf = _cimagfPtr.asFunction(); + + _Fcomplex clogf( + _Fcomplex _Z, + ) { + return _clogf( + _Z, + ); + } + + late final _clogfPtr = + _lookup>('clogf'); + late final _clogf = _clogfPtr.asFunction<_Fcomplex Function(_Fcomplex)>(); + + _Fcomplex clog10f( + _Fcomplex _Z, + ) { + return _clog10f( + _Z, + ); + } + + late final _clog10fPtr = + _lookup>('clog10f'); + late final _clog10f = _clog10fPtr.asFunction<_Fcomplex Function(_Fcomplex)>(); + + _Fcomplex conjf( + _Fcomplex _Z, + ) { + return _conjf( + _Z, + ); + } + + late final _conjfPtr = + _lookup>('conjf'); + late final _conjf = _conjfPtr.asFunction<_Fcomplex Function(_Fcomplex)>(); + + _Fcomplex cpowf( + _Fcomplex _X, + _Fcomplex _Y, + ) { + return _cpowf( + _X, + _Y, + ); + } + + late final _cpowfPtr = + _lookup>( + 'cpowf'); + late final _cpowf = + _cpowfPtr.asFunction<_Fcomplex Function(_Fcomplex, _Fcomplex)>(); + + _Fcomplex cprojf( + _Fcomplex _Z, + ) { + return _cprojf( + _Z, + ); + } + + late final _cprojfPtr = + _lookup>('cprojf'); + late final _cprojf = _cprojfPtr.asFunction<_Fcomplex Function(_Fcomplex)>(); + + double crealf( + _Fcomplex _Z, + ) { + return _crealf( + _Z, + ); + } + + late final _crealfPtr = + _lookup>('crealf'); + late final _crealf = _crealfPtr.asFunction(); + + _Fcomplex csinf( + _Fcomplex _Z, + ) { + return _csinf( + _Z, + ); + } + + late final _csinfPtr = + _lookup>('csinf'); + late final _csinf = _csinfPtr.asFunction<_Fcomplex Function(_Fcomplex)>(); + + _Fcomplex csinhf( + _Fcomplex _Z, + ) { + return _csinhf( + _Z, + ); + } + + late final _csinhfPtr = + _lookup>('csinhf'); + late final _csinhf = _csinhfPtr.asFunction<_Fcomplex Function(_Fcomplex)>(); + + _Fcomplex csqrtf( + _Fcomplex _Z, + ) { + return _csqrtf( + _Z, + ); + } + + late final _csqrtfPtr = + _lookup>('csqrtf'); + late final _csqrtf = _csqrtfPtr.asFunction<_Fcomplex Function(_Fcomplex)>(); + + _Fcomplex ctanf( + _Fcomplex _Z, + ) { + return _ctanf( + _Z, + ); + } + + late final _ctanfPtr = + _lookup>('ctanf'); + late final _ctanf = _ctanfPtr.asFunction<_Fcomplex Function(_Fcomplex)>(); + + _Fcomplex ctanhf( + _Fcomplex _Z, + ) { + return _ctanhf( + _Z, + ); + } + + late final _ctanhfPtr = + _lookup>('ctanhf'); + late final _ctanhf = _ctanhfPtr.asFunction<_Fcomplex Function(_Fcomplex)>(); + + double normf( + _Fcomplex _Z, + ) { + return _normf( + _Z, + ); + } + + late final _normfPtr = + _lookup>('normf'); + late final _normf = _normfPtr.asFunction(); + + _Dcomplex _Cbuild( + double _Re, + double _Im, + ) { + return __Cbuild( + _Re, + _Im, + ); + } + + late final __CbuildPtr = + _lookup>( + '_Cbuild'); + late final __Cbuild = + __CbuildPtr.asFunction<_Dcomplex Function(double, double)>(); + + _Dcomplex _Cmulcc( + _Dcomplex _X, + _Dcomplex _Y, + ) { + return __Cmulcc( + _X, + _Y, + ); + } + + late final __CmulccPtr = + _lookup>( + '_Cmulcc'); + late final __Cmulcc = + __CmulccPtr.asFunction<_Dcomplex Function(_Dcomplex, _Dcomplex)>(); + + _Dcomplex _Cmulcr( + _Dcomplex _X, + double _Y, + ) { + return __Cmulcr( + _X, + _Y, + ); + } + + late final __CmulcrPtr = + _lookup>( + '_Cmulcr'); + late final __Cmulcr = + __CmulcrPtr.asFunction<_Dcomplex Function(_Dcomplex, double)>(); + + _Fcomplex _FCbuild( + double _Re, + double _Im, + ) { + return __FCbuild( + _Re, + _Im, + ); + } + + late final __FCbuildPtr = + _lookup>( + '_FCbuild'); + late final __FCbuild = + __FCbuildPtr.asFunction<_Fcomplex Function(double, double)>(); + + _Fcomplex _FCmulcc( + _Fcomplex _X, + _Fcomplex _Y, + ) { + return __FCmulcc( + _X, + _Y, + ); + } + + late final __FCmulccPtr = + _lookup>( + '_FCmulcc'); + late final __FCmulcc = + __FCmulccPtr.asFunction<_Fcomplex Function(_Fcomplex, _Fcomplex)>(); + + _Fcomplex _FCmulcr( + _Fcomplex _X, + double _Y, + ) { + return __FCmulcr( + _X, + _Y, + ); + } + + late final __FCmulcrPtr = + _lookup>( + '_FCmulcr'); + late final __FCmulcr = + __FCmulcrPtr.asFunction<_Fcomplex Function(_Fcomplex, double)>(); + + void Start( + ffi.Pointer path, + ) { + return _Start( + path, + ); + } + + late final _StartPtr = + _lookup)>>( + 'Start'); + late final _Start = + _StartPtr.asFunction)>(); +} + +typedef va_list = ffi.Pointer; + +final class __crt_locale_data_public extends ffi.Struct { + external ffi.Pointer _locale_pctype; + + @ffi.Int() + external int _locale_mb_cur_max; + + @ffi.UnsignedInt() + external int _locale_lc_codepage; +} + +final class __crt_locale_pointers extends ffi.Struct { + external ffi.Pointer<__crt_locale_data> locinfo; + + external ffi.Pointer<__crt_multibyte_data> mbcinfo; +} + +final class __crt_locale_data extends ffi.Opaque {} + +final class __crt_multibyte_data extends ffi.Opaque {} + +final class _Mbstatet extends ffi.Struct { + @ffi.UnsignedLong() + external int _Wchar; + + @ffi.UnsignedShort() + external int _Byte; + + @ffi.UnsignedShort() + external int _State; +} + +typedef errno_t = ffi.Int; +typedef Darterrno_t = int; + +final class _GoString_ extends ffi.Struct { + external ffi.Pointer p; + + @ptrdiff_t() + external int n; +} + +typedef ptrdiff_t = ffi.LongLong; +typedef Dartptrdiff_t = int; + +final class _C_double_complex extends ffi.Struct { + @ffi.Array.multi([2]) + external ffi.Array _Val; +} + +final class _C_float_complex extends ffi.Struct { + @ffi.Array.multi([2]) + external ffi.Array _Val; +} + +final class _C_ldouble_complex extends ffi.Opaque {} + +typedef _Dcomplex = _C_double_complex; +typedef _Fcomplex = _C_float_complex; + +final class GoInterface extends ffi.Struct { + external ffi.Pointer t; + + external ffi.Pointer v; +} + +final class GoSlice extends ffi.Struct { + external ffi.Pointer data; + + @GoInt() + external int len; + + @GoInt() + external int cap; +} + +typedef GoInt = GoInt64; +typedef GoInt64 = ffi.LongLong; +typedef DartGoInt64 = int; + +const int _VCRT_COMPILER_PREPROCESSOR = 1; + +const int _SAL_VERSION = 20; + +const int __SAL_H_VERSION = 180000000; + +const int _USE_DECLSPECS_FOR_SAL = 0; + +const int _USE_ATTRIBUTES_FOR_SAL = 0; + +const int _CRT_PACKING = 8; + +const int _VCRUNTIME_DISABLED_WARNINGS = 4514; + +const int _HAS_EXCEPTIONS = 1; + +const int _WCHAR_T_DEFINED = 1; + +const int NULL = 0; + +const int _HAS_CXX17 = 0; + +const int _HAS_CXX20 = 0; + +const int _HAS_CXX23 = 0; + +const int _HAS_NODISCARD = 1; + +const int _ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE = 1; + +const int _CRT_BUILD_DESKTOP_APP = 1; + +const int _UCRT_DISABLED_WARNINGS = 4324; + +const int _ARGMAX = 100; + +const int _TRUNCATE = -1; + +const int _CRT_INT_MAX = 2147483647; + +const int _CRT_SIZE_MAX = -1; + +const String __FILEW__ = 'C'; + +const int _CRT_FUNCTIONS_REQUIRED = 1; + +const int _CRT_HAS_CXX17 = 0; + +const int _CRT_HAS_C11 = 0; + +const int _CRT_INTERNAL_NONSTDC_NAMES = 1; + +const int __STDC_SECURE_LIB__ = 200411; + +const int __GOT_SECURE_LIB__ = 200411; + +const int __STDC_WANT_SECURE_LIB__ = 1; + +const int _SECURECRT_FILL_BUFFER_PATTERN = 254; + +const int _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES = 0; + +const int _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_COUNT = 0; + +const int _CRT_SECURE_CPP_OVERLOAD_SECURE_NAMES = 1; + +const int _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_MEMORY = 0; + +const int _CRT_SECURE_CPP_OVERLOAD_SECURE_NAMES_MEMORY = 0; diff --git a/lib/ffi/libmtorrentserver.h b/lib/ffi/libmtorrentserver.h new file mode 100644 index 0000000..9f106dd --- /dev/null +++ b/lib/ffi/libmtorrentserver.h @@ -0,0 +1,81 @@ +/* Code generated by cmd/cgo; DO NOT EDIT. */ + +/* package server/binding/desktop */ + + +#line 1 "cgo-builtin-export-prolog" + +#include + +#ifndef GO_CGO_EXPORT_PROLOGUE_H +#define GO_CGO_EXPORT_PROLOGUE_H + +#ifndef GO_CGO_GOSTRING_TYPEDEF +typedef struct { const char *p; ptrdiff_t n; } _GoString_; +#endif + +#endif + +/* Start of preamble from import "C" comments. */ + + + + +/* End of preamble from import "C" comments. */ + + +/* Start of boilerplate cgo prologue. */ +#line 1 "cgo-gcc-export-header-prolog" + +#ifndef GO_CGO_PROLOGUE_H +#define GO_CGO_PROLOGUE_H + +typedef signed char GoInt8; +typedef unsigned char GoUint8; +typedef short GoInt16; +typedef unsigned short GoUint16; +typedef int GoInt32; +typedef unsigned int GoUint32; +typedef long long GoInt64; +typedef unsigned long long GoUint64; +typedef GoInt64 GoInt; +typedef GoUint64 GoUint; +typedef size_t GoUintptr; +typedef float GoFloat32; +typedef double GoFloat64; +#ifdef _MSC_VER +#include +typedef _Fcomplex GoComplex64; +typedef _Dcomplex GoComplex128; +#else +typedef float _Complex GoComplex64; +typedef double _Complex GoComplex128; +#endif + +/* + static assertion to make sure the file is being used on architecture + at least with matching size of GoInt. +*/ +typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1]; + +#ifndef GO_CGO_GOSTRING_TYPEDEF +typedef _GoString_ GoString; +#endif +typedef void *GoMap; +typedef void *GoChan; +typedef struct { void *t; void *v; } GoInterface; +typedef struct { void *data; GoInt len; GoInt cap; } GoSlice; + +#endif + +/* End of boilerplate cgo prologue. */ + +#ifdef __cplusplus +extern "C" { +#endif + +extern __declspec(dllexport) void Start(char* path); + +#ifdef __cplusplus +} +#endif diff --git a/lib/ffi/torrent_server_ffi.dart b/lib/ffi/torrent_server_ffi.dart new file mode 100644 index 0000000..af1a0b0 --- /dev/null +++ b/lib/ffi/torrent_server_ffi.dart @@ -0,0 +1,32 @@ +import 'dart:ffi'; +import 'dart:io'; + +import 'package:ffi/ffi.dart'; + +import 'generated_bindings.dart'; + +/// A very short-lived native function. +/// +/// For very short-lived functions, it is fine to call them on the main isolate. +/// They will block the Dart execution while running the native function, so +/// only do this for native functions which are guaranteed to be short-lived. +void start(String path) => _bindings.Start(path.toNativeUtf8().cast()); + +const String _libName = 'libmtorrentserver'; + +/// The dynamic library in which the symbols for [NativeAddBindings] can be found. +final DynamicLibrary _dylib = () { + if (Platform.isMacOS) { + return DynamicLibrary.open('$_libName.framework/$_libName'); + } + if (Platform.isLinux) { + return DynamicLibrary.open('$_libName.so'); + } + if (Platform.isWindows) { + return DynamicLibrary.open('$_libName.dll'); + } + throw UnsupportedError('Unknown platform: ${Platform.operatingSystem}'); +}(); + +/// The bindings to the native functions in [_dylib]. +final TorrentLibrary _bindings = TorrentLibrary(_dylib); diff --git a/pubspec.lock b/pubspec.lock index 0d87357..1dab74d 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -403,13 +403,21 @@ packages: source: hosted version: "1.3.1" ffi: - dependency: transitive + dependency: "direct main" description: name: ffi sha256: "7bf0adc28a23d395f19f3f1eb21dd7cfd1dd9f8e1c50051c069122e6853bc878" url: "https://pub.dev" source: hosted version: "2.1.0" + ffigen: + dependency: "direct main" + description: + name: ffigen + sha256: dead012f29db2be71ea152458f5eab600de98fbc244e01088ae6bf2616bceca7 + url: "https://pub.dev" + source: hosted + version: "11.0.0" file: dependency: transitive description: @@ -1612,6 +1620,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.1.2" + yaml_edit: + dependency: transitive + description: + name: yaml_edit + sha256: "1579d4a0340a83cf9e4d580ea51a16329c916973bffd5bd4b45e911b25d46bfd" + url: "https://pub.dev" + source: hosted + version: "2.1.1" sdks: dart: ">=3.2.3 <4.0.0" flutter: ">=3.16.0" diff --git a/pubspec.yaml b/pubspec.yaml index 2f36b23..114fecb 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -64,6 +64,8 @@ dependencies: protobuf: ^3.1.0 cupertino_icons: ^1.0.2 window_manager: ^0.3.7 + ffi: ^2.1.0 + ffigen: ^11.0.0 dependency_overrides: diff --git a/windows/CMakeLists.txt b/windows/CMakeLists.txt index 976b3db..20b358e 100644 --- a/windows/CMakeLists.txt +++ b/windows/CMakeLists.txt @@ -79,6 +79,9 @@ install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR} install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) + +install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/libmtorrentserver.dll" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" diff --git a/windows/libmtorrentserver.dll b/windows/libmtorrentserver.dll new file mode 100644 index 0000000..14452ec Binary files /dev/null and b/windows/libmtorrentserver.dll differ diff --git a/windows/libmtorrentserver.h b/windows/libmtorrentserver.h new file mode 100644 index 0000000..9f106dd --- /dev/null +++ b/windows/libmtorrentserver.h @@ -0,0 +1,81 @@ +/* Code generated by cmd/cgo; DO NOT EDIT. */ + +/* package server/binding/desktop */ + + +#line 1 "cgo-builtin-export-prolog" + +#include + +#ifndef GO_CGO_EXPORT_PROLOGUE_H +#define GO_CGO_EXPORT_PROLOGUE_H + +#ifndef GO_CGO_GOSTRING_TYPEDEF +typedef struct { const char *p; ptrdiff_t n; } _GoString_; +#endif + +#endif + +/* Start of preamble from import "C" comments. */ + + + + +/* End of preamble from import "C" comments. */ + + +/* Start of boilerplate cgo prologue. */ +#line 1 "cgo-gcc-export-header-prolog" + +#ifndef GO_CGO_PROLOGUE_H +#define GO_CGO_PROLOGUE_H + +typedef signed char GoInt8; +typedef unsigned char GoUint8; +typedef short GoInt16; +typedef unsigned short GoUint16; +typedef int GoInt32; +typedef unsigned int GoUint32; +typedef long long GoInt64; +typedef unsigned long long GoUint64; +typedef GoInt64 GoInt; +typedef GoUint64 GoUint; +typedef size_t GoUintptr; +typedef float GoFloat32; +typedef double GoFloat64; +#ifdef _MSC_VER +#include +typedef _Fcomplex GoComplex64; +typedef _Dcomplex GoComplex128; +#else +typedef float _Complex GoComplex64; +typedef double _Complex GoComplex128; +#endif + +/* + static assertion to make sure the file is being used on architecture + at least with matching size of GoInt. +*/ +typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1]; + +#ifndef GO_CGO_GOSTRING_TYPEDEF +typedef _GoString_ GoString; +#endif +typedef void *GoMap; +typedef void *GoChan; +typedef struct { void *t; void *v; } GoInterface; +typedef struct { void *data; GoInt len; GoInt cap; } GoSlice; + +#endif + +/* End of boilerplate cgo prologue. */ + +#ifdef __cplusplus +extern "C" { +#endif + +extern __declspec(dllexport) void Start(char* path); + +#ifdef __cplusplus +} +#endif