Rename Aaru.Console project to Aaru.Logging.

This commit is contained in:
2025-08-17 05:50:25 +01:00
parent 1a6f7a02c6
commit 02ec8a05d8
365 changed files with 5465 additions and 5347 deletions

View File

@@ -33,7 +33,7 @@
<ItemGroup>
<ProjectReference Include="..\Aaru.CommonTypes\Aaru.CommonTypes.csproj"/>
<ProjectReference Include="..\Aaru.Helpers\Aaru.Helpers.csproj"/>
<ProjectReference Include="..\Aaru.Console\Aaru.Console.csproj"/>
<ProjectReference Include="..\Aaru.Logging\Aaru.Logging.csproj"/>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="..\LICENSE.LGPL">

View File

@@ -33,8 +33,8 @@
using System;
using System.Collections.Generic;
using Aaru.Console;
using Aaru.Helpers;
using Aaru.Logging;
namespace Aaru.Checksums;
@@ -82,8 +82,8 @@ public static class CdChecksums
{
case 2448:
{
var subchannel = new byte[96];
var channel = new byte[2352];
byte[] subchannel = new byte[96];
byte[] channel = new byte[2352];
Array.Copy(buffer, 0, channel, 0, 2352);
Array.Copy(buffer, 2352, subchannel, 0, 96);
@@ -121,7 +121,7 @@ public static class CdChecksums
for(uint i = 0; i < 256; i++)
{
uint edc = i;
var j = (uint)(i << 1 ^ ((i & 0x80) == 0x80 ? 0x11D : 0));
uint j = (uint)(i << 1 ^ ((i & 0x80) == 0x80 ? 0x11D : 0));
_eccFTable[i] = (byte)j;
_eccBTable[i ^ j] = (byte)i;
@@ -197,7 +197,7 @@ public static class CdChecksums
{
//AaruConsole.DebugWriteLine(MODULE_NAME, "Mode 0 sector at address {0:X2}:{1:X2}:{2:X2}",
// channel[0x00C], channel[0x00D], channel[0x00E]);
for(var i = 0x010; i < 0x930; i++)
for(int i = 0x010; i < 0x930; i++)
{
if(channel[i] == 0x00) continue;
@@ -233,11 +233,11 @@ public static class CdChecksums
return false;
case 0x01:
{
var address = new byte[4];
var data = new byte[2060];
var data2 = new byte[2232];
var eccP = new byte[172];
var eccQ = new byte[104];
byte[] address = new byte[4];
byte[] data = new byte[2060];
byte[] data2 = new byte[2232];
byte[] eccP = new byte[172];
byte[] eccQ = new byte[104];
Array.Copy(channel, 0x0C, address, 0, 4);
Array.Copy(channel, 0x10, data, 0, 2060);
@@ -269,7 +269,7 @@ public static class CdChecksums
channel[0x00E]);
}
var storedEdc = BitConverter.ToUInt32(channel, 0x810);
uint storedEdc = BitConverter.ToUInt32(channel, 0x810);
uint calculatedEdc = ComputeEdc(0, channel, 0x810);
correctEdc = calculatedEdc == storedEdc;
@@ -292,7 +292,7 @@ public static class CdChecksums
{
//AaruConsole.DebugWriteLine(MODULE_NAME, "Mode 2 sector at address {0:X2}:{1:X2}:{2:X2}",
// channel[0x00C], channel[0x00D], channel[0x00E]);
var mode2Sector = new byte[channel.Length - 0x10];
byte[] mode2Sector = new byte[channel.Length - 0x10];
Array.Copy(channel, 0x10, mode2Sector, 0, mode2Sector.Length);
if((channel[0x012] & 0x20) == 0x20) // mode 2 form 2
@@ -309,7 +309,7 @@ public static class CdChecksums
channel[0x00E]);
}
var storedEdc = BitConverter.ToUInt32(mode2Sector, 0x91C);
uint storedEdc = BitConverter.ToUInt32(mode2Sector, 0x91C);
// No CRC stored!
if(storedEdc == 0x00000000) return true;
@@ -344,9 +344,9 @@ public static class CdChecksums
channel[0x00E]);
}
var address = new byte[4];
var eccP = new byte[172];
var eccQ = new byte[104];
byte[] address = new byte[4];
byte[] eccP = new byte[172];
byte[] eccQ = new byte[104];
Array.Copy(mode2Sector, 0x80C, eccP, 0, 172);
Array.Copy(mode2Sector, 0x8B8, eccQ, 0, 104);
@@ -375,7 +375,7 @@ public static class CdChecksums
channel[0x00E]);
}
var storedEdc = BitConverter.ToUInt32(mode2Sector, 0x808);
uint storedEdc = BitConverter.ToUInt32(mode2Sector, 0x808);
uint calculatedEdc = ComputeEdc(0, mode2Sector, 0x808);
correctEdc = calculatedEdc == storedEdc;
@@ -407,7 +407,7 @@ public static class CdChecksums
static uint ComputeEdc(uint edc, IReadOnlyList<byte> src, int size)
{
var pos = 0;
int pos = 0;
for(; size > 0; size--) edc = edc >> 8 ^ _edcTable[(edc ^ src[pos++]) & 0xFF];
@@ -416,22 +416,22 @@ public static class CdChecksums
static bool? CheckCdSectorSubChannel(IReadOnlyList<byte> subchannel)
{
bool? status = true;
var qSubChannel = new byte[12];
var cdTextPack1 = new byte[18];
var cdTextPack2 = new byte[18];
var cdTextPack3 = new byte[18];
var cdTextPack4 = new byte[18];
var cdSubRwPack1 = new byte[24];
var cdSubRwPack2 = new byte[24];
var cdSubRwPack3 = new byte[24];
var cdSubRwPack4 = new byte[24];
bool? status = true;
byte[] qSubChannel = new byte[12];
byte[] cdTextPack1 = new byte[18];
byte[] cdTextPack2 = new byte[18];
byte[] cdTextPack3 = new byte[18];
byte[] cdTextPack4 = new byte[18];
byte[] cdSubRwPack1 = new byte[24];
byte[] cdSubRwPack2 = new byte[24];
byte[] cdSubRwPack3 = new byte[24];
byte[] cdSubRwPack4 = new byte[24];
var i = 0;
int i = 0;
for(var j = 0; j < 12; j++) qSubChannel[j] = 0;
for(int j = 0; j < 12; j++) qSubChannel[j] = 0;
for(var j = 0; j < 18; j++)
for(int j = 0; j < 18; j++)
{
cdTextPack1[j] = 0;
cdTextPack2[j] = 0;
@@ -439,7 +439,7 @@ public static class CdChecksums
cdTextPack4[j] = 0;
}
for(var j = 0; j < 24; j++)
for(int j = 0; j < 24; j++)
{
cdSubRwPack1[j] = 0;
cdSubRwPack2[j] = 0;
@@ -447,7 +447,7 @@ public static class CdChecksums
cdSubRwPack4[j] = 0;
}
for(var j = 0; j < 12; j++)
for(int j = 0; j < 12; j++)
{
qSubChannel[j] = (byte)(qSubChannel[j] | (subchannel[i++] & 0x40) << 1);
qSubChannel[j] = (byte)(qSubChannel[j] | subchannel[i++] & 0x40);
@@ -461,7 +461,7 @@ public static class CdChecksums
i = 0;
for(var j = 0; j < 18; j++)
for(int j = 0; j < 18; j++)
{
cdTextPack1[j] = (byte)(cdTextPack1[j] | (subchannel[i++] & 0x3F) << 2);
@@ -476,7 +476,7 @@ public static class CdChecksums
cdTextPack1[j] = (byte)(cdTextPack1[j] | subchannel[i++] & 0x3F);
}
for(var j = 0; j < 18; j++)
for(int j = 0; j < 18; j++)
{
cdTextPack2[j] = (byte)(cdTextPack2[j] | (subchannel[i++] & 0x3F) << 2);
@@ -491,7 +491,7 @@ public static class CdChecksums
cdTextPack2[j] = (byte)(cdTextPack2[j] | subchannel[i++] & 0x3F);
}
for(var j = 0; j < 18; j++)
for(int j = 0; j < 18; j++)
{
cdTextPack3[j] = (byte)(cdTextPack3[j] | (subchannel[i++] & 0x3F) << 2);
@@ -506,7 +506,7 @@ public static class CdChecksums
cdTextPack3[j] = (byte)(cdTextPack3[j] | subchannel[i++] & 0x3F);
}
for(var j = 0; j < 18; j++)
for(int j = 0; j < 18; j++)
{
cdTextPack4[j] = (byte)(cdTextPack4[j] | (subchannel[i++] & 0x3F) << 2);
@@ -523,13 +523,13 @@ public static class CdChecksums
i = 0;
for(var j = 0; j < 24; j++) cdSubRwPack1[j] = (byte)(subchannel[i++] & 0x3F);
for(int j = 0; j < 24; j++) cdSubRwPack1[j] = (byte)(subchannel[i++] & 0x3F);
for(var j = 0; j < 24; j++) cdSubRwPack2[j] = (byte)(subchannel[i++] & 0x3F);
for(int j = 0; j < 24; j++) cdSubRwPack2[j] = (byte)(subchannel[i++] & 0x3F);
for(var j = 0; j < 24; j++) cdSubRwPack3[j] = (byte)(subchannel[i++] & 0x3F);
for(int j = 0; j < 24; j++) cdSubRwPack3[j] = (byte)(subchannel[i++] & 0x3F);
for(var j = 0; j < 24; j++) cdSubRwPack4[j] = (byte)(subchannel[i++] & 0x3F);
for(int j = 0; j < 24; j++) cdSubRwPack4[j] = (byte)(subchannel[i++] & 0x3F);
switch(cdSubRwPack1[0])
{
@@ -570,8 +570,8 @@ public static class CdChecksums
break;
}
var qSubChannelCrc = BigEndianBitConverter.ToUInt16(qSubChannel, 10);
var qSubChannelForCrc = new byte[10];
ushort qSubChannelCrc = BigEndianBitConverter.ToUInt16(qSubChannel, 10);
byte[] qSubChannelForCrc = new byte[10];
Array.Copy(qSubChannel, 0, qSubChannelForCrc, 0, 10);
ushort calculatedQcrc = CRC16CcittContext.Calculate(qSubChannelForCrc);
@@ -587,8 +587,8 @@ public static class CdChecksums
if((cdTextPack1[0] & 0x80) == 0x80)
{
var cdTextPack1Crc = BigEndianBitConverter.ToUInt16(cdTextPack1, 16);
var cdTextPack1ForCrc = new byte[16];
ushort cdTextPack1Crc = BigEndianBitConverter.ToUInt16(cdTextPack1, 16);
byte[] cdTextPack1ForCrc = new byte[16];
Array.Copy(cdTextPack1, 0, cdTextPack1ForCrc, 0, 16);
ushort calculatedCdtp1Crc = CRC16CcittContext.Calculate(cdTextPack1ForCrc);
@@ -605,8 +605,8 @@ public static class CdChecksums
if((cdTextPack2[0] & 0x80) == 0x80)
{
var cdTextPack2Crc = BigEndianBitConverter.ToUInt16(cdTextPack2, 16);
var cdTextPack2ForCrc = new byte[16];
ushort cdTextPack2Crc = BigEndianBitConverter.ToUInt16(cdTextPack2, 16);
byte[] cdTextPack2ForCrc = new byte[16];
Array.Copy(cdTextPack2, 0, cdTextPack2ForCrc, 0, 16);
ushort calculatedCdtp2Crc = CRC16CcittContext.Calculate(cdTextPack2ForCrc);
@@ -628,8 +628,8 @@ public static class CdChecksums
if((cdTextPack3[0] & 0x80) == 0x80)
{
var cdTextPack3Crc = BigEndianBitConverter.ToUInt16(cdTextPack3, 16);
var cdTextPack3ForCrc = new byte[16];
ushort cdTextPack3Crc = BigEndianBitConverter.ToUInt16(cdTextPack3, 16);
byte[] cdTextPack3ForCrc = new byte[16];
Array.Copy(cdTextPack3, 0, cdTextPack3ForCrc, 0, 16);
ushort calculatedCdtp3Crc = CRC16CcittContext.Calculate(cdTextPack3ForCrc);
@@ -651,8 +651,8 @@ public static class CdChecksums
if((cdTextPack4[0] & 0x80) != 0x80) return status;
var cdTextPack4Crc = BigEndianBitConverter.ToUInt16(cdTextPack4, 16);
var cdTextPack4ForCrc = new byte[16];
ushort cdTextPack4Crc = BigEndianBitConverter.ToUInt16(cdTextPack4, 16);
byte[] cdTextPack4ForCrc = new byte[16];
Array.Copy(cdTextPack4, 0, cdTextPack4ForCrc, 0, 16);
ushort calculatedCdtp4Crc = CRC16CcittContext.Calculate(cdTextPack4ForCrc);

View File

@@ -59,7 +59,7 @@
using System;
using System.Diagnostics.CodeAnalysis;
using Aaru.Console;
using Aaru.Logging;
namespace Aaru.Checksums;
@@ -194,7 +194,7 @@ public class ReedSolomon
{
int i;
var mask = 1;
int mask = 1;
_alphaTo[_mm] = 0;
for(i = 0; i < _mm; i++)
@@ -299,8 +299,9 @@ public class ReedSolomon
for(i = _kk - 1; i >= 0; i--)
{
if(_mm != 8)
if(data[i] > _nn)
return -1; /* Illegal symbol */
{
if(data[i] > _nn) return -1; /* Illegal symbol */
}
int feedback = _indexOf[data[i] ^ bb[_nn - _kk - 1]];
@@ -354,25 +355,26 @@ public class ReedSolomon
throw new UnauthorizedAccessException(Localization.Trying_to_calculate_RS_without_initializing);
erasPos = new int[_nn - _kk];
int i, j;
int q, tmp;
var recd = new int[_nn];
var lambda = new int[_nn - _kk + 1]; /* Err+Eras Locator poly */
var s = new int[_nn - _kk + 1]; /* syndrome poly */
var b = new int[_nn - _kk + 1];
var t = new int[_nn - _kk + 1];
var omega = new int[_nn - _kk + 1];
var root = new int[_nn - _kk];
var reg = new int[_nn - _kk + 1];
var loc = new int[_nn - _kk];
int count;
int i, j;
int q, tmp;
int[] recd = new int[_nn];
int[] lambda = new int[_nn - _kk + 1]; /* Err+Eras Locator poly */
int[] s = new int[_nn - _kk + 1]; /* syndrome poly */
int[] b = new int[_nn - _kk + 1];
int[] t = new int[_nn - _kk + 1];
int[] omega = new int[_nn - _kk + 1];
int[] root = new int[_nn - _kk];
int[] reg = new int[_nn - _kk + 1];
int[] loc = new int[_nn - _kk];
int count;
/* data[] is in polynomial form, copy and convert to index form */
for(i = _nn - 1; i >= 0; i--)
{
if(_mm != 8)
if(data[i] > _nn)
return -1; /* Illegal symbol */
{
if(data[i] > _nn) return -1; /* Illegal symbol */
}
recd[i] = _indexOf[data[i]];
}
@@ -380,15 +382,16 @@ public class ReedSolomon
/* first form the syndromes; i.e., evaluate recd(x) at roots of g(x)
* namely @**(B0+i), i = 0, ... ,(NN-KK-1)
*/
var synError = 0;
int synError = 0;
for(i = 1; i <= _nn - _kk; i++)
{
tmp = 0;
for(j = 0; j < _nn; j++)
if(recd[j] != _a0) /* recd[j] in index form */
tmp ^= _alphaTo[Modnn(recd[j] + (B0 + i - 1) * j)];
{
if(recd[j] != _a0) /* recd[j] in index form */ tmp ^= _alphaTo[Modnn(recd[j] + (B0 + i - 1) * j)];
}
synError |= tmp; /* set flag if non-zero syndrome =>
* error */
@@ -476,11 +479,12 @@ public class ReedSolomon
{
/* r is the step number */
/* Compute discrepancy at the r-th step in poly-form */
var discrR = 0;
int discrR = 0;
for(i = 0; i < r; i++)
if(lambda[i] != 0 && s[r - i] != _a0)
discrR ^= _alphaTo[Modnn(_indexOf[lambda[i]] + s[r - i])];
{
if(lambda[i] != 0 && s[r - i] != _a0) discrR ^= _alphaTo[Modnn(_indexOf[lambda[i]] + s[r - i])];
}
discrR = _indexOf[discrR]; /* Index form */
@@ -526,7 +530,7 @@ public class ReedSolomon
}
/* Convert lambda to index form and compute deg(lambda(x)) */
var degLambda = 0;
int degLambda = 0;
for(i = 0; i < _nn - _kk + 1; i++)
{
@@ -578,7 +582,7 @@ public class ReedSolomon
* Compute err+eras evaluator poly omega(x) = s(x)*lambda(x) (modulo
* x**(NN-KK)). in index form. Also find deg(omega).
*/
var degOmega = 0;
int degOmega = 0;
for(i = 0; i < _nn - _kk; i++)
{
@@ -586,8 +590,9 @@ public class ReedSolomon
j = degLambda < i ? degLambda : i;
for(; j >= 0; j--)
if(s[i + 1 - j] != _a0 && lambda[j] != _a0)
tmp ^= _alphaTo[Modnn(s[i + 1 - j] + lambda[j])];
{
if(s[i + 1 - j] != _a0 && lambda[j] != _a0) tmp ^= _alphaTo[Modnn(s[i + 1 - j] + lambda[j])];
}
if(tmp != 0) degOmega = i;
@@ -602,19 +607,21 @@ public class ReedSolomon
*/
for(j = count - 1; j >= 0; j--)
{
var num1 = 0;
int num1 = 0;
for(i = degOmega; i >= 0; i--)
if(omega[i] != _a0)
num1 ^= _alphaTo[Modnn(omega[i] + i * root[j])];
{
if(omega[i] != _a0) num1 ^= _alphaTo[Modnn(omega[i] + i * root[j])];
}
int num2 = _alphaTo[Modnn(root[j] * (B0 - 1) + _nn)];
var den = 0;
int den = 0;
/* lambda[i+1] for i even is the formal derivative lambda_pr of lambda[i] */
for(i = Min(degLambda, _nn - _kk - 1) & ~1; i >= 0; i -= 2)
if(lambda[i + 1] != _a0)
den ^= _alphaTo[Modnn(lambda[i + 1] + i * root[j])];
{
if(lambda[i + 1] != _a0) den ^= _alphaTo[Modnn(lambda[i + 1] + i * root[j])];
}
if(den == 0)
{