// myZipView.h : interface of the CMyZipView class
//
/////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_MYZIPVIEW_H__F7A3B44C_F5DF_11D4_BB28_E8506C5DC470__INCLUDED_)
#define AFX_MYZIPVIEW_H__F7A3B44C_F5DF_11D4_BB28_E8506C5DC470__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

typedef struct huffnode {
  struct huffnode   *left;         /* Left child */
  struct huffnode   *right;        /* Right child */
  char              car;          /* Character stored in the node */
  int               freq;          /* Frequency that this char appeared in the file */
} Huffnode;

typedef struct {
  unsigned short  code;
  short           nbits;
} Codes;

// Buffer to hold the data while they are being zipped

#define NFILES 3
#define BUFFERSIZE 50000
#define MAX_LINES 1024

class CMyZipView;

void           extract(char *, CMyZipView *);
Huffnode *     constructtree(HANDLE);
void           decodestream(HANDLE, Huffnode *, char filenames[NFILES][200], int);
void           buildheap(Huffnode **, int);
Huffnode *     buildcodetree(Huffnode **, int);
void           heapify(int, int);
Huffnode *     getmin(Huffnode **, int *);
int            left(int);
int            right(int);
void           insert(Huffnode *, int *, Huffnode **);
int            parent(int);
void           encode(CString ptr[NFILES], int, CMyZipView *);
void           del(Huffnode *);
Huffnode **    getfreq(int *, int);
Codes *        assigncodes(Huffnode *, int);
void           buildstream(HANDLE, Codes *, int);
void           getCodes(Huffnode *, Codes *, 
			unsigned short, short *, short);
void           cleanup(Huffnode *, Codes *);


class CMyZipView : public CScrollView
{
protected: // create from serialization only
	CMyZipView();
	DECLARE_DYNCREATE(CMyZipView)

// Attributes
public:
	CMyZipDoc* GetDocument();
	void OnInitialUpdate();

// Operations
public:

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CMyZipView)
	public:
	virtual void OnDraw(CDC* pDC);  // overridden to draw this view
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
	protected:
	//}}AFX_VIRTUAL

// Implementation
public:
	virtual ~CMyZipView();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

protected:

// Generated message map functions
protected:
	//{{AFX_MSG(CMyZipView)
	afx_msg void OnZipFile();
	afx_msg void OnUnZipFile();
	afx_msg void OnOptions();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

#ifndef _DEBUG  // debug version in myZipView.cpp
inline CMyZipDoc* CMyZipView::GetDocument()
   { return (CMyZipDoc*)m_pDocument; }
#endif

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_MYZIPVIEW_H__F7A3B44C_F5DF_11D4_BB28_E8506C5DC470__INCLUDED_)
