migration done
This commit is contained in:
@@ -7,17 +7,16 @@ import 'dart:ffi' as ffi;
|
||||
class NativeLibrary {
|
||||
/// Holds the symbol lookup function.
|
||||
final ffi.Pointer<T> Function<T extends ffi.NativeType>(String symbolName)
|
||||
_lookup;
|
||||
_lookup;
|
||||
|
||||
/// The symbols are looked up in [dynamicLibrary].
|
||||
NativeLibrary(ffi.DynamicLibrary dynamicLibrary)
|
||||
: _lookup = dynamicLibrary.lookup;
|
||||
: _lookup = dynamicLibrary.lookup;
|
||||
|
||||
/// The symbols are looked up with [lookup].
|
||||
NativeLibrary.fromLookup(
|
||||
ffi.Pointer<T> Function<T extends ffi.NativeType>(String symbolName)
|
||||
lookup)
|
||||
: _lookup = lookup;
|
||||
ffi.Pointer<T> Function<T extends ffi.NativeType>(String symbolName) lookup,
|
||||
) : _lookup = lookup;
|
||||
|
||||
Tor tor_start(
|
||||
int socks_port,
|
||||
@@ -37,13 +36,30 @@ class NativeLibrary {
|
||||
);
|
||||
}
|
||||
|
||||
late final _tor_startPtr = _lookup<
|
||||
ffi.NativeFunction<
|
||||
Tor Function(ffi.Uint16, ffi.Pointer<ffi.Char>, ffi.Pointer<ffi.Char>,
|
||||
ffi.Uint16, ffi.Uint16, ffi.Pointer<ffi.Char>)>>('tor_start');
|
||||
late final _tor_start = _tor_startPtr.asFunction<
|
||||
Tor Function(int, ffi.Pointer<ffi.Char>, ffi.Pointer<ffi.Char>, int, int,
|
||||
ffi.Pointer<ffi.Char>)>();
|
||||
late final _tor_startPtr =
|
||||
_lookup<
|
||||
ffi.NativeFunction<
|
||||
Tor Function(
|
||||
ffi.Uint16,
|
||||
ffi.Pointer<ffi.Char>,
|
||||
ffi.Pointer<ffi.Char>,
|
||||
ffi.Uint16,
|
||||
ffi.Uint16,
|
||||
ffi.Pointer<ffi.Char>,
|
||||
)
|
||||
>
|
||||
>('tor_start');
|
||||
late final _tor_start = _tor_startPtr
|
||||
.asFunction<
|
||||
Tor Function(
|
||||
int,
|
||||
ffi.Pointer<ffi.Char>,
|
||||
ffi.Pointer<ffi.Char>,
|
||||
int,
|
||||
int,
|
||||
ffi.Pointer<ffi.Char>,
|
||||
)
|
||||
>();
|
||||
|
||||
bool tor_reconfigure(
|
||||
ffi.Pointer<ffi.Void> client,
|
||||
@@ -63,70 +79,71 @@ class NativeLibrary {
|
||||
);
|
||||
}
|
||||
|
||||
late final _tor_reconfigurePtr = _lookup<
|
||||
ffi.NativeFunction<
|
||||
late final _tor_reconfigurePtr =
|
||||
_lookup<
|
||||
ffi.NativeFunction<
|
||||
ffi.Bool Function(
|
||||
ffi.Pointer<ffi.Void>,
|
||||
ffi.Pointer<ffi.Char>,
|
||||
ffi.Pointer<ffi.Char>,
|
||||
ffi.Uint16,
|
||||
ffi.Uint16,
|
||||
ffi.Pointer<ffi.Char>)>>('tor_reconfigure');
|
||||
late final _tor_reconfigure = _tor_reconfigurePtr.asFunction<
|
||||
bool Function(ffi.Pointer<ffi.Void>, ffi.Pointer<ffi.Char>,
|
||||
ffi.Pointer<ffi.Char>, int, int, ffi.Pointer<ffi.Char>)>();
|
||||
ffi.Pointer<ffi.Void>,
|
||||
ffi.Pointer<ffi.Char>,
|
||||
ffi.Pointer<ffi.Char>,
|
||||
ffi.Uint16,
|
||||
ffi.Uint16,
|
||||
ffi.Pointer<ffi.Char>,
|
||||
)
|
||||
>
|
||||
>('tor_reconfigure');
|
||||
late final _tor_reconfigure = _tor_reconfigurePtr
|
||||
.asFunction<
|
||||
bool Function(
|
||||
ffi.Pointer<ffi.Void>,
|
||||
ffi.Pointer<ffi.Char>,
|
||||
ffi.Pointer<ffi.Char>,
|
||||
int,
|
||||
int,
|
||||
ffi.Pointer<ffi.Char>,
|
||||
)
|
||||
>();
|
||||
|
||||
bool tor_client_bootstrap(
|
||||
ffi.Pointer<ffi.Void> client,
|
||||
) {
|
||||
return _tor_client_bootstrap(
|
||||
client,
|
||||
);
|
||||
bool tor_client_bootstrap(ffi.Pointer<ffi.Void> client) {
|
||||
return _tor_client_bootstrap(client);
|
||||
}
|
||||
|
||||
late final _tor_client_bootstrapPtr =
|
||||
_lookup<ffi.NativeFunction<ffi.Bool Function(ffi.Pointer<ffi.Void>)>>(
|
||||
'tor_client_bootstrap');
|
||||
'tor_client_bootstrap',
|
||||
);
|
||||
late final _tor_client_bootstrap = _tor_client_bootstrapPtr
|
||||
.asFunction<bool Function(ffi.Pointer<ffi.Void>)>();
|
||||
|
||||
void tor_client_set_dormant(
|
||||
ffi.Pointer<ffi.Void> client,
|
||||
bool soft_mode,
|
||||
) {
|
||||
return _tor_client_set_dormant(
|
||||
client,
|
||||
soft_mode,
|
||||
);
|
||||
void tor_client_set_dormant(ffi.Pointer<ffi.Void> client, bool soft_mode) {
|
||||
return _tor_client_set_dormant(client, soft_mode);
|
||||
}
|
||||
|
||||
late final _tor_client_set_dormantPtr = _lookup<
|
||||
ffi
|
||||
.NativeFunction<ffi.Void Function(ffi.Pointer<ffi.Void>, ffi.Bool)>>(
|
||||
'tor_client_set_dormant');
|
||||
late final _tor_client_set_dormantPtr =
|
||||
_lookup<
|
||||
ffi.NativeFunction<ffi.Void Function(ffi.Pointer<ffi.Void>, ffi.Bool)>
|
||||
>('tor_client_set_dormant');
|
||||
late final _tor_client_set_dormant = _tor_client_set_dormantPtr
|
||||
.asFunction<void Function(ffi.Pointer<ffi.Void>, bool)>();
|
||||
|
||||
void tor_proxy_stop(
|
||||
ffi.Pointer<ffi.Void> proxy,
|
||||
) {
|
||||
return _tor_proxy_stop(
|
||||
proxy,
|
||||
);
|
||||
void tor_proxy_stop(ffi.Pointer<ffi.Void> proxy) {
|
||||
return _tor_proxy_stop(proxy);
|
||||
}
|
||||
|
||||
late final _tor_proxy_stopPtr =
|
||||
_lookup<ffi.NativeFunction<ffi.Void Function(ffi.Pointer<ffi.Void>)>>(
|
||||
'tor_proxy_stop');
|
||||
late final _tor_proxy_stop =
|
||||
_tor_proxy_stopPtr.asFunction<void Function(ffi.Pointer<ffi.Void>)>();
|
||||
'tor_proxy_stop',
|
||||
);
|
||||
late final _tor_proxy_stop = _tor_proxy_stopPtr
|
||||
.asFunction<void Function(ffi.Pointer<ffi.Void>)>();
|
||||
|
||||
void tor_hello() {
|
||||
return _tor_hello();
|
||||
}
|
||||
|
||||
late final _tor_helloPtr =
|
||||
_lookup<ffi.NativeFunction<ffi.Void Function()>>('tor_hello');
|
||||
late final _tor_helloPtr = _lookup<ffi.NativeFunction<ffi.Void Function()>>(
|
||||
'tor_hello',
|
||||
);
|
||||
late final _tor_hello = _tor_helloPtr.asFunction<void Function()>();
|
||||
|
||||
ffi.Pointer<ffi.Char> tor_last_error_message() {
|
||||
@@ -135,9 +152,10 @@ class NativeLibrary {
|
||||
|
||||
late final _tor_last_error_messagePtr =
|
||||
_lookup<ffi.NativeFunction<ffi.Pointer<ffi.Char> Function()>>(
|
||||
'tor_last_error_message');
|
||||
late final _tor_last_error_message =
|
||||
_tor_last_error_messagePtr.asFunction<ffi.Pointer<ffi.Char> Function()>();
|
||||
'tor_last_error_message',
|
||||
);
|
||||
late final _tor_last_error_message = _tor_last_error_messagePtr
|
||||
.asFunction<ffi.Pointer<ffi.Char> Function()>();
|
||||
|
||||
int tor_get_nofile_limit() {
|
||||
return _tor_get_nofile_limit();
|
||||
@@ -145,23 +163,21 @@ class NativeLibrary {
|
||||
|
||||
late final _tor_get_nofile_limitPtr =
|
||||
_lookup<ffi.NativeFunction<ffi.Uint64 Function()>>(
|
||||
'tor_get_nofile_limit');
|
||||
late final _tor_get_nofile_limit =
|
||||
_tor_get_nofile_limitPtr.asFunction<int Function()>();
|
||||
'tor_get_nofile_limit',
|
||||
);
|
||||
late final _tor_get_nofile_limit = _tor_get_nofile_limitPtr
|
||||
.asFunction<int Function()>();
|
||||
|
||||
int tor_set_nofile_limit(
|
||||
int limit,
|
||||
) {
|
||||
return _tor_set_nofile_limit(
|
||||
limit,
|
||||
);
|
||||
int tor_set_nofile_limit(int limit) {
|
||||
return _tor_set_nofile_limit(limit);
|
||||
}
|
||||
|
||||
late final _tor_set_nofile_limitPtr =
|
||||
_lookup<ffi.NativeFunction<ffi.Uint64 Function(ffi.Uint64)>>(
|
||||
'tor_set_nofile_limit');
|
||||
late final _tor_set_nofile_limit =
|
||||
_tor_set_nofile_limitPtr.asFunction<int Function(int)>();
|
||||
'tor_set_nofile_limit',
|
||||
);
|
||||
late final _tor_set_nofile_limit = _tor_set_nofile_limitPtr
|
||||
.asFunction<int Function(int)>();
|
||||
}
|
||||
|
||||
typedef __u_char = ffi.UnsignedChar;
|
||||
@@ -391,10 +407,10 @@ typedef pthread_key_t = ffi.UnsignedInt;
|
||||
typedef Dartpthread_key_t = int;
|
||||
typedef pthread_once_t = ffi.Int;
|
||||
typedef Dartpthread_once_t = int;
|
||||
typedef __compar_fn_tFunction = ffi.Int Function(
|
||||
ffi.Pointer<ffi.Void>, ffi.Pointer<ffi.Void>);
|
||||
typedef Dart__compar_fn_tFunction = int Function(
|
||||
ffi.Pointer<ffi.Void>, ffi.Pointer<ffi.Void>);
|
||||
typedef __compar_fn_tFunction =
|
||||
ffi.Int Function(ffi.Pointer<ffi.Void>, ffi.Pointer<ffi.Void>);
|
||||
typedef Dart__compar_fn_tFunction =
|
||||
int Function(ffi.Pointer<ffi.Void>, ffi.Pointer<ffi.Void>);
|
||||
typedef __compar_fn_t = ffi.Pointer<ffi.NativeFunction<__compar_fn_tFunction>>;
|
||||
|
||||
final class Tor extends ffi.Struct {
|
||||
|
||||
@@ -20,11 +20,11 @@ environment:
|
||||
flutter: '>=3.3.0'
|
||||
|
||||
dependencies:
|
||||
ffi: ^2.0.1
|
||||
ffi: ^2.1.4
|
||||
flutter:
|
||||
sdk: flutter
|
||||
path_provider: ^2.1.4
|
||||
plugin_platform_interface: ^2.0.2
|
||||
path_provider: ^2.1.5
|
||||
plugin_platform_interface: ^2.1.8
|
||||
|
||||
dev_dependencies:
|
||||
ffigen: ^19.1.0
|
||||
|
||||
Reference in New Issue
Block a user