checkpoint
This commit is contained in:
345
Alpm/Junk.cs
Normal file
345
Alpm/Junk.cs
Normal file
@@ -0,0 +1,345 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Foodsoft.Alpm
|
||||
{
|
||||
|
||||
/*
|
||||
* Hooks
|
||||
*/
|
||||
|
||||
enum alpm_hook_when_t
|
||||
{
|
||||
HOOK_PRE_TRANSACTION = 1,
|
||||
HOOK_POST_TRANSACTION
|
||||
}
|
||||
|
||||
/*
|
||||
* Logging facilities
|
||||
*/
|
||||
|
||||
/** Logging Levels */
|
||||
enum _alpm_loglevel_t
|
||||
{
|
||||
LOG_ERROR = 1,
|
||||
LOG_WARNING = (1 << 1),
|
||||
LOG_DEBUG = (1 << 2),
|
||||
LOG_FUNCTION = (1 << 3)
|
||||
}
|
||||
|
||||
|
||||
/** Location a package object was loaded from. */
|
||||
enum alpm_pkgfrom_t
|
||||
{
|
||||
PKG_FROM_FILE = 1,
|
||||
PKG_FROM_LOCALDB,
|
||||
PKG_FROM_SYNCDB
|
||||
}
|
||||
|
||||
/** Method used to validate a package. */
|
||||
enum alpm_pkgvalidation_t
|
||||
{
|
||||
PKG_VALIDATION_UNKNOWN = 0,
|
||||
PKG_VALIDATION_NONE = (1 << 0),
|
||||
PKG_VALIDATION_MD5SUM = (1 << 1),
|
||||
PKG_VALIDATION_SHA256SUM = (1 << 2),
|
||||
PKG_VALIDATION_SIGNATURE = (1 << 3)
|
||||
}
|
||||
|
||||
/** Types of version constraints in dependency specs. */
|
||||
public enum alpm_depmod_t
|
||||
{
|
||||
/** No version constraint */
|
||||
DEP_MOD_ANY = 1,
|
||||
|
||||
/** Test version equality (package=x.y.z) */
|
||||
DEP_MOD_EQ,
|
||||
|
||||
/** Test for at least a version (package>=x.y.z) */
|
||||
DEP_MOD_GE,
|
||||
|
||||
/** Test for at most a version (package<=x.y.z) */
|
||||
DEP_MOD_LE,
|
||||
|
||||
/** Test for greater than some version (package>x.y.z) */
|
||||
DEP_MOD_GT,
|
||||
|
||||
/** Test for less than some version (package<x.y.z) */
|
||||
DEP_MOD_LT
|
||||
}
|
||||
|
||||
/**
|
||||
* File conflict type.
|
||||
* Whether the conflict results from a file existing on the filesystem, or with
|
||||
* another target in the transaction.
|
||||
*/
|
||||
enum alpm_fileconflicttype_t
|
||||
{
|
||||
FILECONFLICT_TARGET = 1,
|
||||
FILECONFLICT_FILESYSTEM
|
||||
}
|
||||
|
||||
/** PGP signature verification options */
|
||||
[Flags]
|
||||
public enum SigLevel
|
||||
{
|
||||
SIG_PACKAGE = (1 << 0),
|
||||
SIG_PACKAGE_OPTIONAL = (1 << 1),
|
||||
SIG_PACKAGE_MARGINAL_OK = (1 << 2),
|
||||
SIG_PACKAGE_UNKNOWN_OK = (1 << 3),
|
||||
|
||||
SIG_DATABASE = (1 << 10),
|
||||
SIG_DATABASE_OPTIONAL = (1 << 11),
|
||||
SIG_DATABASE_MARGINAL_OK = (1 << 12),
|
||||
SIG_DATABASE_UNKNOWN_OK = (1 << 13),
|
||||
SIG_USE_DEFAULT = (1 << 31)
|
||||
}
|
||||
|
||||
/** PGP signature verification status return codes */
|
||||
enum alpm_sigstatus_t
|
||||
{
|
||||
SIGSTATUS_VALID,
|
||||
SIGSTATUS_KEY_EXPIRED,
|
||||
SIGSTATUS_SIG_EXPIRED,
|
||||
SIGSTATUS_KEY_UNKNOWN,
|
||||
SIGSTATUS_KEY_DISABLED,
|
||||
SIGSTATUS_INVALID
|
||||
}
|
||||
|
||||
/** PGP signature verification status return codes */
|
||||
enum alpm_sigvalidity_t
|
||||
{
|
||||
SIGVALIDITY_FULL,
|
||||
SIGVALIDITY_MARGINAL,
|
||||
SIGVALIDITY_NEVER,
|
||||
SIGVALIDITY_UNKNOWN
|
||||
}
|
||||
|
||||
/** Dependency */
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
public struct alpm_depend_t
|
||||
{
|
||||
string name;
|
||||
string version;
|
||||
string desc;
|
||||
public ulong name_hash;
|
||||
public alpm_depmod_t mod;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct AlpmDependPtr
|
||||
{
|
||||
private IntPtr ptr;
|
||||
|
||||
public alpm_depend_t Unmarshal()
|
||||
{
|
||||
return Marshal.PtrToStructure<alpm_depend_t>(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
/** Missing dependency */
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
public struct alpm_depmissing_t
|
||||
{
|
||||
public string target;
|
||||
|
||||
public AlpmDependPtr depend;
|
||||
|
||||
/* this is used only in the case of a remove dependency error */
|
||||
public string causingpkg;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
/** Conflict */
|
||||
public struct alpm_conflict_t
|
||||
{
|
||||
public ulong package1_hash;
|
||||
public ulong package2_hash;
|
||||
public string package1;
|
||||
public string package2;
|
||||
public AlpmDependPtr reason;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
/** File conflict */
|
||||
struct alpm_fileconflict_t
|
||||
{
|
||||
public string target;
|
||||
public alpm_fileconflicttype_t type;
|
||||
public string file;
|
||||
public string ctarget;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
/** Package group */
|
||||
public readonly struct alpm_group_t
|
||||
{
|
||||
/** group name */
|
||||
public readonly string name;
|
||||
|
||||
/** list of alpm_pkg_t packages */
|
||||
private readonly unsafe alpm_list_t* packages;
|
||||
}
|
||||
|
||||
/* TODO: alpm_pkg_get_files - need to wrap */
|
||||
/** File in a package */
|
||||
public readonly struct alpm_file_t
|
||||
{
|
||||
public readonly string name;
|
||||
public readonly UIntPtr size;
|
||||
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<alpm_file_t>() * 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
|
||||
{
|
||||
string name;
|
||||
string hash;
|
||||
}
|
||||
|
||||
public class alpm_pgpkey_t
|
||||
{
|
||||
public byte[] data;
|
||||
public string fingerprint;
|
||||
public string uid;
|
||||
public string name;
|
||||
public string email;
|
||||
public long created;
|
||||
public long expires;
|
||||
public uint revoked;
|
||||
public char pubkey_algo;
|
||||
}
|
||||
|
||||
public class PgpKeyInMarshaler : ICustomMarshaler
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
private class NativePgpKey
|
||||
{
|
||||
public IntPtr data;
|
||||
public string fingerprint;
|
||||
public string uid;
|
||||
public string name;
|
||||
public string email;
|
||||
public long created;
|
||||
public long expires;
|
||||
public uint length;
|
||||
public uint revoked;
|
||||
public char pubkey_algo;
|
||||
}
|
||||
|
||||
public void CleanUpManagedData(object ManagedObj) { }
|
||||
public void CleanUpNativeData(IntPtr pNativeData) { }
|
||||
|
||||
public int GetNativeDataSize()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IntPtr MarshalManagedToNative(object ManagedObj)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public object MarshalNativeToManaged(IntPtr pNativeData)
|
||||
{
|
||||
var raw = Marshal.PtrToStructure<NativePgpKey>(pNativeData);
|
||||
var managed = new alpm_pgpkey_t()
|
||||
{
|
||||
data = new byte[raw.length],
|
||||
fingerprint = raw.fingerprint,
|
||||
uid = raw.uid,
|
||||
name = raw.name,
|
||||
email = raw.email,
|
||||
created = raw.created,
|
||||
expires = raw.expires,
|
||||
revoked = raw.revoked,
|
||||
pubkey_algo = raw.pubkey_algo
|
||||
};
|
||||
Marshal.Copy(raw.data, managed.data, 0, (int) raw.length);
|
||||
return managed;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Signature result. Contains the key, status, and validity of a given
|
||||
* signature.
|
||||
*/
|
||||
public readonly struct alpm_sigresult_t
|
||||
{
|
||||
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PgpKeyInMarshaler))]
|
||||
readonly alpm_pgpkey_t key;
|
||||
|
||||
readonly alpm_sigstatus_t status;
|
||||
readonly alpm_sigvalidity_t validity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Signature list. Contains the number of signatures found and a pointer to an
|
||||
* array of results. The array is of size count.
|
||||
*/
|
||||
public class SigListInMarshaler : ICustomMarshaler
|
||||
{
|
||||
public void CleanUpManagedData(object ManagedObj) { }
|
||||
public void CleanUpNativeData(IntPtr pNativeData) { }
|
||||
|
||||
public int GetNativeDataSize()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IntPtr MarshalManagedToNative(object ManagedObj)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public object MarshalNativeToManaged(IntPtr pNativeData)
|
||||
{
|
||||
UIntPtr count;
|
||||
IntPtr data;
|
||||
unsafe
|
||||
{
|
||||
count = *(UIntPtr*) pNativeData;
|
||||
data = *(IntPtr*) (pNativeData + sizeof(UIntPtr));
|
||||
}
|
||||
|
||||
var iCount = (int) count;
|
||||
var result = new alpm_sigresult_t[iCount];
|
||||
// NOTE: I expect this to fail cuz i didn't implement the above GetNativeDataSize
|
||||
for (var i = 0; i < iCount; ++i, data += Marshal.SizeOf<alpm_sigresult_t>())
|
||||
{
|
||||
result[i] = Marshal.PtrToStructure<alpm_sigresult_t>(data);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user