byte [] outBuf = new byte [inSize];
// was this decoder already initialized?
if(! initialized)
throw new YencException("No data input vector set");
// step through the input data
for(int j = dataOffset; j < inSize; j++, byteCount++)
{
// read input character
int i = (int) inputData[j];
// skip end of line
if(i == 10 || i == 13)
continue;
// check for escape character
if(i == '=' && (j + 1) < inSize)
{
// parse footer
try
{
if(inputData[j + 1] == 'y' && checkFooter(inputData, j))
break;
}
catch(YencException ex)
{
runnable.crc32Error();
}
// decode a non-yenc-meta-character
j++;
i = (int) inputData[j];
i = (i - 64) % 256;
}
// subtract the 42 offset and send the result to the output
i = (i - 42) % 256;
outBuf[outBufCounter++] = (byte) i;
crc32Obj.update(i);
}
// create new output buffer as the first one will be too long,
// because of the CR/LF chars in the original data
byte [] newOutBuf = new byte[outBufCounter];
System.arraycopy(outBuf, 0, newOutBuf, 0, outBufCounter);
initialized = false;
if(!footerFound)
throw new YencException("No yenc footer found");
else
footerFound = false;
return newOutBuf;
}