File: XADARJFastestHandle.m

package info (click to toggle)
unar 1.1-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 6,664 kB
  • sloc: ansic: 52,939; objc: 39,563; cpp: 4,074; makefile: 99; perl: 10
file content (118 lines) | stat: -rw-r--r-- 2,255 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#import "XADARJFastestHandle.h"

@implementation XADARJFastestHandle

-(id)initWithHandle:(CSHandle *)handle length:(off_t)length
{
	return [super initWithHandle:handle length:length windowSize:0x8000];
}

-(void)resetLZSSHandle
{
}

-(int)nextLiteralOrOffset:(int *)offset andLength:(int *)length atPosition:(off_t)pos
{
	int val=0;
	int pow=0;
	while(pow<7)
	{
		if(!CSInputNextBit(input)) break;
		val+=1<<pow;
		pow++;
	}
	if(pow) val+=CSInputNextBitString(input,pow);

	if(!val) return CSInputNextBitString(input,8);
	else
	{
		int offs=0;
		int pow=9;
		while(pow<13)
		{
			if(!CSInputNextBit(input)) break;
			offs+=1<<pow;
			pow++;
		}
		offs+=CSInputNextBitString(input,pow);

		*offset=offs+1;
		*length=val+2;

		return XADLZSSMatch;
	}
}

@end

/*

#define ARJSTRTP         9
#define ARJSTOPP        13

#define ARJSTRTL         0
#define ARJSTOPL         7

static xadINT32 ARJ_Decrunch(struct xadInOut *io)
{
  struct xadMasterBase *xadMasterBase = io->xio_xadMasterBase;
  xadINT32 err;
  xadUINT32 dicsiz = (1<<15);
  xadSTRPTR text;
  xadINT16 i, c, width, pwr;
  xadUINT32 loc = 0;

  if((text = xadAllocVec(XADM dicsiz, XADMEMF_PUBLIC|XADMEMF_CLEAR)))
  {
    --dicsiz;
    while(!(io->xio_Flags & (XADIOF_LASTOUTBYTE|XADIOF_ERROR)))
    {
      c = 0;
      pwr = 1 << (ARJSTRTL);
      for(width = (ARJSTRTL); width < (ARJSTOPL); width++)
      {
        if(!xadIOGetBitsHigh(io, 1))
          break;
        c += pwr;
        pwr <<= 1;
      }
      if(width)
        c += xadIOGetBitsHigh(io, width);

      if(!c)
      {
        text[loc++] = xadIOPutChar(io, xadIOGetBitsHigh(io, 8));
        loc &= dicsiz;
      }
      else
      {
        c += 3 - 1;

        i = 0;
        pwr = 1 << (ARJSTRTP);
        for(width = (ARJSTRTP); width < (ARJSTOPP); width++)
        {
          if(!xadIOGetBitsHigh(io, 1))
            break;
          i += pwr;
          pwr <<= 1;
        }
        if(width)
          i += xadIOGetBitsHigh(io, width);
        i = loc - i - 1;
        while(c--)
        {
          text[loc++] = xadIOPutChar(io, text[i++ & dicsiz]);
          loc &= dicsiz;
        }
      }
    }
    err = io->xio_Error;
    xadFreeObjectA(XADM text, 0);
  }
  else
    err = XADERR_NOMEMORY;

  return err;
}
*/