home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 1997 December
/
VPR9712A.ISO
/
OLS
/
OS2
/
LHA2P205
/
LHA2P205.LZH
/
lha2-2.05pre
/
source.lzh
/
src
/
larc.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-10-23
|
2KB
|
99 lines
/*
* larc.c --- extract *.lzs
* Copyright (C) 1988-1992, Haruyasu YOSHIZAKI
*
* $Log$
*/
#include <sys/types.h>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include "typedef.h"
#include "slidehuf.h"
#include "intrface.h"
#define MAGIC0 18
#define MAGIC5 19
static int flag, flagcnt, matchpos;
ushort
decode_c_lzs(void)
{
if(getbits(1))
return getbits(8);
else
{
matchpos = getbits(11);
return getbits(4) + 0x100;
}
}
ushort
decode_p_lzs(void)
{
return (ushort)(loc - matchpos - MAGIC0) & 0x7ff;
}
void
decode_start_lzs(void)
{
init_getbits();
}
ushort
decode_c_lz5(void)
{
int c;
if(flagcnt == 0)
{
flagcnt = 8;
flag = getc(infile);
}
flagcnt--;
c = getc(infile);
if(((uint)flag & 1) == 0)
{
matchpos = c;
c = getc(infile);
matchpos += ((uint)c & 0xf0) << 4;
c = (uint)c & 0x0f;
c += 0x100;
}
flag = (uint)flag >> 1;
return (ushort)c;
}
ushort
decode_p_lz5(void)
{
return (ushort)(loc - matchpos - MAGIC5) & 0xfff;
}
void
decode_start_lz5(void)
{
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);
}