/***********************************************************************
  This file is part of HA, a general purpose file archiver.
  Copyright (C) 1995 Harri Hirvola

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
************************************************************************
	HA ASC method
***********************************************************************/

#ifndef Included_asc_h
#define Included_asc_h

#include "ha.h"
#include "haio.h"
#include "acoder.h"
#include "swdict.h"


#define POSCODES 31200
#define SLCODES	16
#define LLCODES 48
#define LLLEN	16
#define LLBITS	4
#define LLMASK	(LLLEN-1)
#define LENCODES (SLCODES+LLCODES*LLLEN)
#define LTCODES (SLCODES+LLCODES)
#define CTCODES 256
#define PTCODES 16
#define LTSTEP 8
#define MAXLT (750*LTSTEP)
#define CTSTEP 1
#define MAXCT (1000*CTSTEP)
#define PTSTEP 24
#define MAXPT (250*PTSTEP) 
#define TTSTEP 40
#define MAXTT (150*TTSTEP)
#define TTORD 4
#define TTOMASK (TTORD-1);
#define LCUTOFF (3*LTSTEP)
#define CCUTOFF (3*CTSTEP)
#define CPLEN 8
#define LPLEN 4
#define MINLENLIM 4096

struct asc
{
	struct haio *haio;
	struct acoder *ac;
	struct swdict *swd;

	U16B ltab[2*LTCODES];
	U16B eltab[2*LTCODES];
	U16B ptab[2*PTCODES];
	U16B ctab[2*CTCODES];
	U16B ectab[2*CTCODES];
	U16B ttab[TTORD][2];
	U16B ccnt,pmax,npt;
	U16B ces;
	U16B les;
	U16B ttcon;
};

/*	Setup for ASC method
*/
struct asc *asc_setup(void);

/*	ASC method packing function
*/
U32B asc_pack(struct asc *asc, unsigned char *ibuf, U32B ilen, unsigned char *obuf, U32B olen);

/*	ASC method unpacking function
*/
U32B asc_unpack(struct asc *asc, unsigned char *ibuf, U32B ilen, unsigned char *obuf, U32B olen);

/*	Cleanup for ASC method
*/
void asc_cleanup(struct asc *asc);

#endif/* !Included_asc_h */

