diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..03b6ce0
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,67 @@
+
+[*]
+charset=utf-8
+end_of_line=lf
+trim_trailing_whitespace=false
+insert_final_newline=false
+indent_style=space
+indent_size=4
+
+# Microsoft .NET properties
+csharp_new_line_before_members_in_object_initializers=false
+csharp_preferred_modifier_order=public, private, protected, internal, new, abstract, virtual, sealed, override, static, readonly, extern, unsafe, volatile, async:suggestion
+csharp_style_var_elsewhere=true:suggestion
+csharp_style_var_for_built_in_types=true:suggestion
+csharp_style_var_when_type_is_apparent=true:suggestion
+dotnet_naming_rule.private_constants_rule.severity=warning
+dotnet_naming_rule.private_constants_rule.style=upper_camel_case_style
+dotnet_naming_rule.private_constants_rule.symbols=private_constants_symbols
+dotnet_naming_rule.private_static_readonly_rule.severity=warning
+dotnet_naming_rule.private_static_readonly_rule.style=lower_camel_case_style
+dotnet_naming_rule.private_static_readonly_rule.symbols=private_static_readonly_symbols
+dotnet_naming_style.lower_camel_case_style.capitalization=camel_case
+dotnet_naming_style.lower_camel_case_style.required_prefix=_
+dotnet_naming_style.upper_camel_case_style.capitalization=pascal_case
+dotnet_naming_symbols.private_constants_symbols.applicable_accessibilities=private
+dotnet_naming_symbols.private_constants_symbols.applicable_kinds=field
+dotnet_naming_symbols.private_constants_symbols.required_modifiers=const
+dotnet_naming_symbols.private_static_readonly_symbols.applicable_accessibilities=private
+dotnet_naming_symbols.private_static_readonly_symbols.applicable_kinds=field
+dotnet_naming_symbols.private_static_readonly_symbols.required_modifiers=static,readonly
+dotnet_style_parentheses_in_arithmetic_binary_operators=never_if_unnecessary:none
+dotnet_style_parentheses_in_other_binary_operators=never_if_unnecessary:none
+dotnet_style_parentheses_in_relational_binary_operators=never_if_unnecessary:none
+dotnet_style_predefined_type_for_locals_parameters_members=true:suggestion
+dotnet_style_predefined_type_for_member_access=true:suggestion
+dotnet_style_qualification_for_event=false:suggestion
+dotnet_style_qualification_for_field=false:suggestion
+dotnet_style_qualification_for_method=false:suggestion
+dotnet_style_qualification_for_property=false:suggestion
+dotnet_style_require_accessibility_modifiers=for_non_interface_members:suggestion
+
+# ReSharper properties
+resharper_autodetect_indent_settings=true
+resharper_csharp_naming_rule.private_static_readonly=_ + aaBb, aaBb
+resharper_empty_block_style=together_same_line
+resharper_use_indent_from_vs=false
+
+# ReSharper inspection severities
+resharper_arrange_redundant_parentheses_highlighting=hint
+resharper_arrange_this_qualifier_highlighting=hint
+resharper_arrange_type_member_modifiers_highlighting=hint
+resharper_arrange_type_modifiers_highlighting=hint
+resharper_built_in_type_reference_style_for_member_access_highlighting=hint
+resharper_built_in_type_reference_style_highlighting=hint
+resharper_delegate_subtraction_highlighting=hint
+resharper_redundant_base_qualifier_highlighting=warning
+resharper_suggest_var_or_type_built_in_types_highlighting=hint
+resharper_suggest_var_or_type_elsewhere_highlighting=hint
+resharper_suggest_var_or_type_simple_types_highlighting=hint
+resharper_web_config_module_not_resolved_highlighting=warning
+resharper_web_config_type_not_resolved_highlighting=warning
+resharper_web_config_wrong_module_highlighting=warning
+
+[*.{appxmanifest,asax,ascx,aspx,build,cs,cshtml,dtd,fs,fsi,fsscript,fsx,master,ml,mli,nuspec,razor,resw,resx,skin,vb,xaml,xamlx,xoml,xsd}]
+indent_style=space
+indent_size=4
+tab_width=4
diff --git a/Alpm/Alpm.csproj b/Alpm/Alpm.csproj
index 69449f0..8e4a326 100644
--- a/Alpm/Alpm.csproj
+++ b/Alpm/Alpm.csproj
@@ -1,14 +1,20 @@
-
-
-
- netcoreapp3.1
- true
- enable
- Foodsoft.Alpm
-
-
-
-
-
-
-
+
+
+
+ netcoreapp3.1
+ true
+ enable
+ Foodsoft.Alpm
+ true
+ DotNetAlpm
+
+ DotNetAlpm
+ (C) 2020 The DotNetAlpm authors
+ MIT
+
+
+
+
+
+
+
diff --git a/Alpm/AssemblyInfo.cs b/Alpm/AssemblyInfo.cs
new file mode 100644
index 0000000..2bacd57
--- /dev/null
+++ b/Alpm/AssemblyInfo.cs
@@ -0,0 +1,3 @@
+using System;
+
+[assembly: CLSCompliant(true)]
\ No newline at end of file
diff --git a/Alpm/Capabilities.cs b/Alpm/Capabilities.cs
new file mode 100644
index 0000000..aaad9af
--- /dev/null
+++ b/Alpm/Capabilities.cs
@@ -0,0 +1,12 @@
+using System;
+
+namespace Foodsoft.Alpm
+{
+ [Flags]
+ public enum Capabilities
+ {
+ Nls = (1 << 0),
+ Downloader = (1 << 1),
+ Signatures = (1 << 2)
+ }
+}
\ No newline at end of file
diff --git a/Alpm/Depend.cs b/Alpm/Depend.cs
index d3ea9db..2ea4c18 100644
--- a/Alpm/Depend.cs
+++ b/Alpm/Depend.cs
@@ -11,14 +11,14 @@ namespace Foodsoft.Alpm
Name = Marshal.PtrToStringUTF8(native->name)!;
Version = Marshal.PtrToStringUTF8(native->version)!;
Description = Marshal.PtrToStringUTF8(native->description)!;
- NameHash = native->name_hash;
+ NameHash = (long)native->name_hash;
Mod = native->mod;
}
public string Name { get; }
public string Version { get; }
public string Description { get; }
- public ulong NameHash { get; }
+ public Int64 NameHash { get; }
public ModType Mod { get; }
public bool Equals(Depend? other)
diff --git a/Alpm/Detail.cs b/Alpm/Detail.cs
index a304322..5a41888 100644
--- a/Alpm/Detail.cs
+++ b/Alpm/Detail.cs
@@ -44,7 +44,7 @@ namespace Foodsoft.Alpm
{
return handle.UseHandle(handle.DangerousGetHandle(), op);
}
-
+
internal static void SetStringCollection(IEnumerable value, SafeAlpmHandle safeAlpmHandle,
Func op)
{
diff --git a/Alpm/File.cs b/Alpm/File.cs
index 5e49501..886b5de 100644
--- a/Alpm/File.cs
+++ b/Alpm/File.cs
@@ -8,7 +8,7 @@ namespace Foodsoft.Alpm
public string Name { get; }
public long Size { get; }
- public uint Mode { get; }
+ public int Mode { get; }
[StructLayout(LayoutKind.Sequential)]
internal readonly unsafe struct NativeFile
@@ -23,7 +23,7 @@ namespace Foodsoft.Alpm
var native = (NativeFile*) ptr;
Name = new string(native->Name);
Size = native->size;
- Mode = native->mode;
+ Mode = (int) native->mode;
}
}
}
\ No newline at end of file
diff --git a/Alpm/Handle.cs b/Alpm/Handle.cs
index 51ac99c..7e69b5c 100644
--- a/Alpm/Handle.cs
+++ b/Alpm/Handle.cs
@@ -9,7 +9,7 @@ namespace Foodsoft.Alpm
private readonly object _eventLock = new object();
private readonly SafeAlpmHandle _handle;
- private EventHandler _logEvent;
+ private EventHandler? _logEvent;
public Handle(string root, string dbPath)
{
@@ -26,7 +26,7 @@ namespace Foodsoft.Alpm
set => Detail.SetStringCollection(value, _handle, s => alpm.alpm_option_add_cachedir(_handle, s));
}
- public LogLevel LogLevel { get; set; }
+ public LogLevel LogLevel { get; set; } = LogLevel.Error;
public void Dispose()
{
@@ -54,7 +54,7 @@ namespace Foodsoft.Alpm
public bool RemoveCacheDir(string dir)
{
- return Detail.WrapErrorBool(_handle, () => alpm.alpm_option_add_cachedir(_handle, dir));
+ return Detail.WrapErrorBool(_handle, () => alpm.alpm_option_remove_cachedir(_handle, dir));
}
public bool ShouldIgnorePackage(Package pkg)
diff --git a/Alpm/Junk.cs b/Alpm/Junk.cs
index c1981ab..fec67d8 100644
--- a/Alpm/Junk.cs
+++ b/Alpm/Junk.cs
@@ -2,8 +2,8 @@ using System;
using System.Runtime.InteropServices;
namespace Foodsoft.Alpm
-{
-
+{
+
/*
* Hooks
*/
@@ -158,33 +158,6 @@ namespace Foodsoft.Alpm
public readonly uint mode;
}
- public enum caps
- {
- ALPM_CAPABILITY_NLS = (1 << 0),
- ALPM_CAPABILITY_DOWNLOADER = (1 << 1),
- ALPM_CAPABILITY_SIGNATURES = (1 << 2)
- }
-
- /** Package filelist container */
- public struct _alpm_filelist_t
- {
- public UIntPtr count;
- private IntPtr files;
-
- /* FIXME: This is broken as shit */
- public alpm_file_t[] Unmarshal()
- {
- var iCount = (int) this.count;
- var byteCount = Marshal.SizeOf() * iCount;
- var byteBuffer = new byte[byteCount];
- Marshal.Copy(files, byteBuffer, 0, byteBuffer.Length);
- var result = new alpm_file_t[iCount];
-
- Buffer.BlockCopy(byteBuffer, 0, result, 0, byteBuffer.Length);
- return result;
- }
- }
-
/** Local package or package file backup entry */
public struct _alpm_backup_t
{
diff --git a/Alpm/alpm.cs b/Alpm/alpm.cs
index ace1ef4..fbebd39 100644
--- a/Alpm/alpm.cs
+++ b/Alpm/alpm.cs
@@ -14,273 +14,272 @@ namespace Foodsoft.Alpm
}
// ReSharper disable once InconsistentNaming
+ // ReSharper disable IdentifierTypo
internal static class alpm
{
- public delegate void alpm_fn_free(IntPtr ptr);
-
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern int alpm_pkg_should_ignore(SafeAlpmHandle handle, SafePackageHandle pkg);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Return))]
public static extern string alpm_pkg_get_filename(SafePackageHandle pkg);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Return))]
public static extern string alpm_pkg_get_base(SafePackageHandle pkg);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Return))]
public static extern string alpm_pkg_get_name(SafePackageHandle pkg);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Return))]
public static extern string alpm_pkg_get_name(IntPtr pkg);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Return))]
public static extern string alpm_pkg_get_version(SafePackageHandle pkg);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern PackageOrigin alpm_pkg_get_origin(SafePackageHandle pkg);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Return))]
public static extern string alpm_pkg_get_desc(SafePackageHandle pkg);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Return))]
public static extern string alpm_pkg_get_url(SafePackageHandle pkg);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern long alpm_pkg_get_builddate(SafePackageHandle pkg);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern long alpm_pkg_get_installdate(SafePackageHandle pkg);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Return))]
public static extern string alpm_pkg_get_packager(SafePackageHandle pkg);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Return))]
public static extern string alpm_pkg_get_md5sum(SafePackageHandle pkg);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Return))]
public static extern string alpm_pkg_get_sha256sum(SafePackageHandle pkg);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Return))]
public static extern string alpm_pkg_get_arch(SafePackageHandle pkg);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern long alpm_pkg_get_size(SafePackageHandle pkg);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern long alpm_pkg_get_isize(SafePackageHandle pkg);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern InstallReason alpm_pkg_get_reason(SafePackageHandle pkg);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr alpm_pkg_get_licenses(SafePackageHandle pkg);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr alpm_pkg_get_groups(SafePackageHandle pkg);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr alpm_pkg_get_depends(SafePackageHandle pkg);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr alpm_pkg_get_optdepends(SafePackageHandle pkg);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr alpm_pkg_get_checkdepends(SafePackageHandle pkg);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr alpm_pkg_get_makedepends(SafePackageHandle pkg);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr alpm_pkg_get_conflicts(SafePackageHandle pkg);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr alpm_pkg_get_provides(SafePackageHandle pkg);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr alpm_pkg_get_replaces(SafePackageHandle pkg);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr alpm_pkg_get_files(SafePackageHandle pkg);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr alpm_pkg_get_backup(SafePackageHandle pkg);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr alpm_filelist_contains(IntPtr fileList,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8In))]
string path);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Return))]
public static extern string alpm_pkg_get_base64_sig(SafePackageHandle pkg);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern ValidationType alpm_pkg_get_validation(SafePackageHandle pkg);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern bool alpm_pkg_has_scriptlet(SafePackageHandle pkg);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern long alpm_pkg_download_size(SafePackageHandle pkg);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern int alpm_pkg_set_reason(SafePackageHandle pkg, InstallReason reason);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern int alpm_pkg_checkmd5sum(SafePackageHandle pkg);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern int alpm_pkg_free(IntPtr ptr);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate void LogFuncCallBack(LogLevel level, IntPtr format, IntPtr argsAddress);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr alpm_option_set_logcb(SafeAlpmHandle handle, LogFuncCallBack? cb);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr alpm_option_get_cachedirs(SafeAlpmHandle handle);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern int alpm_option_add_cachedir(SafeAlpmHandle handle,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8In))]
string cachedir);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern int alpm_option_remove_cachedir(SafeAlpmHandle handle,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8In))]
string cachedir);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern ErrorCode alpm_errno(SafeAlpmHandle handle);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Return))]
public static extern string alpm_strerror(ErrorCode err);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr alpm_get_localdb(SafeAlpmHandle handle);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern unsafe alpm_list_t* alpm_option_get_syncdbs();
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr alpm_register_syncdb(SafeAlpmHandle handle,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8In))]
string treename, SigLevel sigLevel);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern int alpm_db_unregister_all_syncdbs(SafeAlpmHandle handle);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr alpm_list_append(ref IntPtr list, IntPtr item);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr alpm_list_append_strdup(ref IntPtr list,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8In))]
string str);
-
- [DllImport(nameof(alpm))]
- public static extern IntPtr alpm_list_next(IntPtr list);
-
- [DllImport(nameof(alpm))]
+
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern UIntPtr alpm_list_count(IntPtr list);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern void alpm_list_free(IntPtr list);
- [DllImport(nameof(alpm))]
- public static extern void alpm_list_free_inner(IntPtr list, alpm_fn_free freeFn);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ public delegate void AlpmFnFree(IntPtr ptr);
+
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
+ public static extern void alpm_list_free_inner(IntPtr list, AlpmFnFree freeFn);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr alpm_list_find_str(IntPtr list,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8In))]
string needle);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern int alpm_unlock(Handle handle);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Return))]
public static extern string alpm_version();
- [DllImport(nameof(alpm))]
- public static extern caps alpm_capabilities();
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
+ public static extern Capabilities alpm_capabilities();
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern SafeAlpmHandle alpm_initialize(
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8In))]
string root, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8In))]
string dbpath, out ErrorCode err);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern int alpm_release(IntPtr handle);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern int alpm_db_remove_server(SafeDatabaseHandle db,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8In))]
string url);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern int alpm_db_unregister(IntPtr db);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Return))]
public static extern string alpm_db_get_name(SafeDatabaseHandle db);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern SigLevel alpm_db_get_siglevel(SafeDatabaseHandle db);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern int alpm_db_get_valid(SafeDatabaseHandle db);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern int alpm_db_update(int force, SafeDatabaseHandle db);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr alpm_db_get_servers(SafeDatabaseHandle db);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern int alpm_db_set_servers(SafeDatabaseHandle db, IntPtr list);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern int alpm_db_add_server(SafeDatabaseHandle db,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8In))]
string url);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern int alpm_db_get_usage(SafeDatabaseHandle db, out Database.UsageFlags usage);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern int alpm_db_set_usage(SafeDatabaseHandle db, Database.UsageFlags usage);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr alpm_db_search(SafeDatabaseHandle db, IntPtr needles);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr alpm_pkg_get_pkg(SafeDatabaseHandle db,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8In))]
string name);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr alpm_db_get_pkgcache(SafeDatabaseHandle db);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern int alpm_pkg_vercmp(string v1, string v2);
- [DllImport(nameof(alpm))]
+ [DllImport(nameof(alpm), CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr alpm_find_satisfier(IntPtr pkgList, string depstring);
}
}
\ No newline at end of file
diff --git a/Samples/Program.cs b/Samples/Program.cs
index 855a38c..88959b7 100644
--- a/Samples/Program.cs
+++ b/Samples/Program.cs
@@ -52,17 +52,27 @@ namespace Samples
public int Run(string[] args)
{
using var h = new Handle("/", "/var/lib/pacman");
+
+
+ static void OnHOnLog(object? sender, Handle.LogEventArgs eventArgs)
+ {
+ Console.Write(eventArgs.Message);
+ }
+
+ h.LogLevel = LogLevel.Debug;
+ h.Log += OnHOnLog;
+
using var db = h.RegisterSyncDB("core");
db.Servers = new[] {"http://www.google.com"};
- //using var pkg = db.PackageCache.FindSatisfier("gcc=9.3.0-1");
- var result = db.Search(new[] {"gcc", "objc"});
- foreach (var pkg in result)
- using (pkg)
- {
- Console.WriteLine($"{pkg?.Name} {pkg?.Version}");
- }
+ using var pkg = db.PackageCache.FindSatisfier("gcc=9.3.0");
+ // var result = db.Search(new[] {"gcc", "objc"});
+ // foreach (var pkg in result)
+ // using (pkg)
+ // {
+ // Console.WriteLine($"{pkg?.Name} {pkg?.Version}");
+ // }
return 0;