Skip to content

Commit 99c0f14

Browse files
committed
Clean separation for XDR reading and writing.
1 parent 1f76215 commit 99c0f14

33 files changed

+1422
-1580
lines changed

Provider/src/FirebirdSql.Data.External/FirebirdSql.Data.External.projitems

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
</PropertyGroup>
1111
<ItemGroup>
1212
<Compile Include="$(MSBuildThisFileDirectory)RC4\ICipherParameters.cs" />
13-
<Compile Include="$(MSBuildThisFileDirectory)RC4\IStreamCipher.cs" />
1413
<Compile Include="$(MSBuildThisFileDirectory)RC4\KeyParameter.cs" />
1514
<Compile Include="$(MSBuildThisFileDirectory)RC4\RC4Engine.cs" />
1615
<Compile Include="$(MSBuildThisFileDirectory)zlib\Deflate.cs" />

Provider/src/FirebirdSql.Data.External/RC4/IStreamCipher.cs

Lines changed: 0 additions & 45 deletions
This file was deleted.

Provider/src/FirebirdSql.Data.External/RC4/RC4Engine.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace Org.BouncyCastle.Crypto.Engines
77
{
88
internal class RC4Engine
9-
: IStreamCipher
9+
//: IStreamCipher
1010
{
1111
private readonly static int STATE_LENGTH = 256;
1212

Provider/src/FirebirdSql.Data.External/zlib/Deflate.cs

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -386,11 +386,11 @@ private void _InitializeTreeData()
386386
internal void _InitializeBlocks()
387387
{
388388
// Initialize the trees.
389-
for (var i = 0; i < InternalConstants.L_CODES; i++)
389+
for (int i = 0; i < InternalConstants.L_CODES; i++)
390390
dyn_ltree[i * 2] = 0;
391-
for (var i = 0; i < InternalConstants.D_CODES; i++)
391+
for (int i = 0; i < InternalConstants.D_CODES; i++)
392392
dyn_dtree[i * 2] = 0;
393-
for (var i = 0; i < InternalConstants.BL_CODES; i++)
393+
for (int i = 0; i < InternalConstants.BL_CODES; i++)
394394
bl_tree[i * 2] = 0;
395395

396396
dyn_ltree[END_BLOCK * 2] = 1;
@@ -404,8 +404,8 @@ internal void _InitializeBlocks()
404404
// two sons).
405405
internal void pqdownheap(short[] tree, int k)
406406
{
407-
var v = heap[k];
408-
var j = k << 1; // left son of k
407+
int v = heap[k];
408+
int j = k << 1; // left son of k
409409
while (j <= heap_len)
410410
{
411411
// Set j to the smallest of the two sons:
@@ -427,8 +427,8 @@ internal void pqdownheap(short[] tree, int k)
427427

428428
internal static bool _IsSmaller(short[] tree, int n, int m, sbyte[] depth)
429429
{
430-
var tn2 = tree[n * 2];
431-
var tm2 = tree[m * 2];
430+
short tn2 = tree[n * 2];
431+
short tm2 = tree[m * 2];
432432
return (tn2 < tm2 || (tn2 == tm2 && depth[n] <= depth[m]));
433433
}
434434

@@ -438,12 +438,12 @@ internal static bool _IsSmaller(short[] tree, int n, int m, sbyte[] depth)
438438
internal void scan_tree(short[] tree, int max_code)
439439
{
440440
int n; // iterates over all tree elements
441-
var prevlen = -1; // last emitted length
441+
int prevlen = -1; // last emitted length
442442
int curlen; // length of current code
443-
var nextlen = (int)tree[0 * 2 + 1]; // length of next code
444-
var count = 0; // repeat count of the current code
445-
var max_count = 7; // max repeat count
446-
var min_count = 4; // min repeat count
443+
int nextlen = (int)tree[0 * 2 + 1]; // length of next code
444+
int count = 0; // repeat count of the current code
445+
int max_count = 7; // max repeat count
446+
int min_count = 4; // min repeat count
447447

448448
if (nextlen == 0)
449449
{
@@ -545,12 +545,12 @@ internal void send_all_trees(int lcodes, int dcodes, int blcodes)
545545
internal void send_tree(short[] tree, int max_code)
546546
{
547547
int n; // iterates over all tree elements
548-
var prevlen = -1; // last emitted length
548+
int prevlen = -1; // last emitted length
549549
int curlen; // length of current code
550550
int nextlen = tree[0 * 2 + 1]; // length of next code
551-
var count = 0; // repeat count of the current code
552-
var max_count = 7; // max repeat count
553-
var min_count = 4; // min repeat count
551+
int count = 0; // repeat count of the current code
552+
int max_count = 7; // max repeat count
553+
int min_count = 4; // min repeat count
554554

555555
if (nextlen == 0)
556556
{
@@ -640,13 +640,13 @@ internal void putShortMSB(int b)
640640

641641
internal void send_code(int c, short[] tree)
642642
{
643-
var c2 = c * 2;
643+
int c2 = c * 2;
644644
send_bits((tree[c2] & 0xffff), (tree[c2 + 1] & 0xffff));
645645
}
646646

647647
internal void send_bits(int value, int length)
648648
{
649-
var len = length;
649+
int len = length;
650650
unchecked
651651
{
652652
if (bi_valid > (int)Buf_size - len)
@@ -728,8 +728,8 @@ internal bool _tr_tally(int dist, int lc)
728728
if ((last_lit & 0x1fff) == 0 && (int)compressionLevel > 2)
729729
{
730730
// Compute an upper bound for the compressed length
731-
var out_length = last_lit << 3;
732-
var in_length = strstart - block_start;
731+
int out_length = last_lit << 3;
732+
int in_length = strstart - block_start;
733733
int dcode;
734734
for (dcode = 0; dcode < InternalConstants.D_CODES; dcode++)
735735
{
@@ -754,15 +754,15 @@ internal void send_compressed_block(short[] ltree, short[] dtree)
754754
{
755755
int distance; // distance of matched string
756756
int lc; // match length or unmatched char (if dist == 0)
757-
var lx = 0; // running index in l_buf
757+
int lx = 0; // running index in l_buf
758758
int code; // the code to send
759759
int extra; // number of extra bits to send
760760

761761
if (last_lit != 0)
762762
{
763763
do
764764
{
765-
var ix = _distanceOffset + lx * 2;
765+
int ix = _distanceOffset + lx * 2;
766766
distance = ((pending[ix] << 8) & 0xff00) |
767767
(pending[ix + 1] & 0xff);
768768
lc = (pending[_lengthOffset + lx]) & 0xff;
@@ -819,9 +819,9 @@ internal void send_compressed_block(short[] ltree, short[] dtree)
819819
// frequencies does not exceed 64K (to fit in an int on 16 bit machines).
820820
internal void set_data_type()
821821
{
822-
var n = 0;
823-
var ascii_freq = 0;
824-
var bin_freq = 0;
822+
int n = 0;
823+
int ascii_freq = 0;
824+
int bin_freq = 0;
825825
while (n < 7)
826826
{
827827
bin_freq += dyn_ltree[n * 2]; n++;
@@ -915,7 +915,7 @@ internal BlockState DeflateNone(FlushType flush)
915915
// Stored blocks are limited to 0xffff bytes, pending is limited
916916
// to pending_buf_size, and each stored block has a 5 byte header:
917917

918-
var max_block_size = 0xffff;
918+
int max_block_size = 0xffff;
919919
int max_start;
920920

921921
if (max_block_size > pending.Length - 5)
@@ -982,7 +982,7 @@ internal void _tr_stored_block(int buf, int stored_len, bool eof)
982982
internal void _tr_flush_block(int buf, int stored_len, bool eof)
983983
{
984984
int opt_lenb, static_lenb; // opt_len and static_len in bytes
985-
var max_blindex = 0; // index of last bit length code of non zero freq
985+
int max_blindex = 0; // index of last bit length code of non zero freq
986986

987987
// Build the Huffman trees unless a stored block is forced
988988
if (compressionLevel > 0)
@@ -1152,7 +1152,7 @@ private void _fillWindow()
11521152
internal BlockState DeflateFast(FlushType flush)
11531153
{
11541154
// short hash_head = 0; // head of the hash chain
1155-
var hash_head = 0; // head of the hash chain
1155+
int hash_head = 0; // head of the hash chain
11561156
bool bflush; // set if current block must be flushed
11571157

11581158
while (true)
@@ -1271,7 +1271,7 @@ internal BlockState DeflateFast(FlushType flush)
12711271
internal BlockState DeflateSlow(FlushType flush)
12721272
{
12731273
// short hash_head = 0; // head of hash chain
1274-
var hash_head = 0; // head of hash chain
1274+
int hash_head = 0; // head of hash chain
12751275
bool bflush; // set if current block must be flushed
12761276

12771277
// Process the input block.
@@ -1336,7 +1336,7 @@ internal BlockState DeflateSlow(FlushType flush)
13361336
// match is not better, output the previous match:
13371337
if (prev_length >= MIN_MATCH && match_length <= prev_length)
13381338
{
1339-
var max_insert = strstart + lookahead - MIN_MATCH;
1339+
int max_insert = strstart + lookahead - MIN_MATCH;
13401340
// Do not insert strings in hash table beyond this.
13411341

13421342
// check_match(strstart-1, prev_match, prev_length);
@@ -1422,23 +1422,23 @@ internal BlockState DeflateSlow(FlushType flush)
14221422

14231423
internal int longest_match(int cur_match)
14241424
{
1425-
var chain_length = config.MaxChainLength; // max hash chain length
1426-
var scan = strstart; // current string
1425+
int chain_length = config.MaxChainLength; // max hash chain length
1426+
int scan = strstart; // current string
14271427
int match; // matched string
14281428
int len; // length of current match
1429-
var best_len = prev_length; // best match length so far
1430-
var limit = strstart > (w_size - MIN_LOOKAHEAD) ? strstart - (w_size - MIN_LOOKAHEAD) : 0;
1429+
int best_len = prev_length; // best match length so far
1430+
int limit = strstart > (w_size - MIN_LOOKAHEAD) ? strstart - (w_size - MIN_LOOKAHEAD) : 0;
14311431

1432-
var niceLength = config.NiceLength;
1432+
int niceLength = config.NiceLength;
14331433

14341434
// Stop when cur_match becomes <= limit. To simplify the code,
14351435
// we prevent matches with the string of window index 0.
14361436

1437-
var wmask = w_mask;
1437+
int wmask = w_mask;
14381438

1439-
var strend = strstart + MAX_MATCH;
1440-
var scan_end1 = window[scan + best_len - 1];
1441-
var scan_end = window[scan + best_len];
1439+
int strend = strstart + MAX_MATCH;
1440+
byte scan_end1 = window[scan + best_len - 1];
1441+
byte scan_end = window[scan + best_len];
14421442

14431443
// The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
14441444
// It is easy to get rid of this optimization if necessary.
@@ -1640,11 +1640,11 @@ private void SetDeflater()
16401640

16411641
internal int SetParams(CompressionLevel level, CompressionStrategy strategy)
16421642
{
1643-
var result = ZlibConstants.Z_OK;
1643+
int result = ZlibConstants.Z_OK;
16441644

16451645
if (compressionLevel != level)
16461646
{
1647-
var newConfig = Config.Lookup(level);
1647+
Config newConfig = Config.Lookup(level);
16481648

16491649
// change in the deflate flavor (Fast vs slow vs none)?
16501650
if (newConfig.Flavor != config.Flavor && _codec.TotalBytesIn != 0)
@@ -1667,8 +1667,8 @@ internal int SetParams(CompressionLevel level, CompressionStrategy strategy)
16671667

16681668
internal int SetDictionary(byte[] dictionary)
16691669
{
1670-
var length = dictionary.Length;
1671-
var index = 0;
1670+
int length = dictionary.Length;
1671+
int index = 0;
16721672

16731673
if (dictionary == null || status != INIT_STATE)
16741674
throw new ZlibException("Stream error.");
@@ -1693,7 +1693,7 @@ internal int SetDictionary(byte[] dictionary)
16931693
ins_h = window[0] & 0xff;
16941694
ins_h = (((ins_h) << hash_shift) ^ (window[1] & 0xff)) & hash_mask;
16951695

1696-
for (var n = 0; n <= length - MIN_MATCH; n++)
1696+
for (int n = 0; n <= length - MIN_MATCH; n++)
16971697
{
16981698
ins_h = (((ins_h) << hash_shift) ^ (window[(n) + (MIN_MATCH - 1)] & 0xff)) & hash_mask;
16991699
prev[n & w_mask] = head[ins_h];
@@ -1727,8 +1727,8 @@ internal int Deflate(FlushType flush)
17271727
// Write the zlib (rfc1950) header bytes
17281728
if (status == INIT_STATE)
17291729
{
1730-
var header = (Z_DEFLATED + ((w_bits - 8) << 4)) << 8;
1731-
var level_flags = (((int)compressionLevel - 1) & 0xff) >> 1;
1730+
int header = (Z_DEFLATED + ((w_bits - 8) << 4)) << 8;
1731+
int level_flags = (((int)compressionLevel - 1) & 0xff) >> 1;
17321732

17331733
if (level_flags > 3)
17341734
level_flags = 3;
@@ -1802,7 +1802,7 @@ internal int Deflate(FlushType flush)
18021802
// Start a new block or continue the current one.
18031803
if (_codec.AvailableBytesIn != 0 || lookahead != 0 || (flush != FlushType.None && status != FINISH_STATE))
18041804
{
1805-
var bstate = DeflateFunction(flush);
1805+
BlockState bstate = DeflateFunction(flush);
18061806

18071807
if (bstate == BlockState.FinishStarted || bstate == BlockState.FinishDone)
18081808
{
@@ -1838,7 +1838,7 @@ internal int Deflate(FlushType flush)
18381838
if (flush == FlushType.Full)
18391839
{
18401840
// clear hash (forget the history)
1841-
for (var i = 0; i < hash_size; i++)
1841+
for (int i = 0; i < hash_size; i++)
18421842
head[i] = 0;
18431843
}
18441844
}

0 commit comments

Comments
 (0)