X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=src%2Flarc.c;h=c6f8f1ca111705a11dd744ac01e458e95377366d;hb=ea219082575096f592ce2f40bae3ae7720b63212;hp=3ddef3b0492cb6414311036814740ee312eb4e34;hpb=077cef7772dffae0d607aeb199b515c5027e25c6;p=lha%2Flha.git diff --git a/src/larc.c b/src/larc.c index 3ddef3b..c6f8f1c 100644 --- a/src/larc.c +++ b/src/larc.c @@ -1,88 +1,92 @@ /* ------------------------------------------------------------------------ */ -/* LHa for UNIX */ -/* larc.c -- extra *.lzs */ -/* */ -/* Modified Nobutaka Watazaki */ -/* */ -/* Ver. 1.14 Source All chagned 1995.01.14 N.Watazaki */ +/* LHa for UNIX */ +/* larc.c -- extra *.lzs */ +/* */ +/* Modified Nobutaka Watazaki */ +/* */ +/* Ver. 1.14 Source All chagned 1995.01.14 N.Watazaki */ /* ------------------------------------------------------------------------ */ #include "lha.h" /* ------------------------------------------------------------------------ */ static int flag, flagcnt, matchpos; /* ------------------------------------------------------------------------ */ +/* lzs */ unsigned short decode_c_lzs( /*void*/ ) { - if (getbits(1)) { - return getbits(8); - } - else { - matchpos = getbits(11); - return getbits(4) + 0x100; - } + if (getbits(1)) { + return getbits(8); + } + else { + matchpos = getbits(11); + return getbits(4) + 0x100; + } } /* ------------------------------------------------------------------------ */ +/* lzs */ unsigned short decode_p_lzs( /*void*/ ) { - return (loc - matchpos - MAGIC0) & 0x7ff; + return (loc - matchpos - MAGIC0) & 0x7ff; } /* ------------------------------------------------------------------------ */ +/* lzs */ void decode_start_lzs( /*void*/ ) { - init_getbits(); + init_getbits(); + init_code_cache(); } /* ------------------------------------------------------------------------ */ +/* lz5 */ unsigned short decode_c_lz5( /*void*/ ) { - int c; + int c; - if (flagcnt == 0) { - flagcnt = 8; - flag = getc(infile); - } - flagcnt--; - c = getc(infile); - if ((flag & 1) == 0) { - matchpos = c; - c = getc(infile); - matchpos += (c & 0xf0) << 4; - c &= 0x0f; - c += 0x100; - } - flag >>= 1; - return c; + if (flagcnt == 0) { + flagcnt = 8; + flag = getc(infile); + } + flagcnt--; + c = getc(infile); + if ((flag & 1) == 0) { + matchpos = c; + c = getc(infile); + matchpos += (c & 0xf0) << 4; + c &= 0x0f; + c += 0x100; + } + flag >>= 1; + return c; } /* ------------------------------------------------------------------------ */ +/* lz5 */ unsigned short decode_p_lz5( /*void*/ ) { - return (loc - matchpos - MAGIC5) & 0xfff; + return (loc - matchpos - MAGIC5) & 0xfff; } /* ------------------------------------------------------------------------ */ +/* lz5 */ void decode_start_lz5( /*void*/ ) { - int i; + int i; - flagcnt = 0; - for (i = 0; i < 256; i++) - memset(&text[i * 13 + 18], i, 13); - for (i = 0; i < 256; i++) - text[256 * 13 + 18 + i] = i; - for (i = 0; i < 256; i++) - text[256 * 13 + 256 + 18 + i] = 255 - i; - memset(&text[256 * 13 + 512 + 18], 0, 128); - memset(&text[256 * 13 + 512 + 128 + 18], ' ', 128 - 18); + flagcnt = 0; + for (i = 0; i < 256; i++) + memset(&dtext[i * 13 + 18], i, 13); + for (i = 0; i < 256; i++) + dtext[256 * 13 + 18 + i] = i; + for (i = 0; i < 256; i++) + dtext[256 * 13 + 256 + 18 + i] = 255 - i; + memset(&dtext[256 * 13 + 512 + 18], 0, 128); + memset(&dtext[256 * 13 + 512 + 128 + 18], ' ', 128 - 18); } -/* Local Variables: */ -/* tab-width : 4 */ -/* End: */