LzwComp.c ( File view )

  • By ninjaes 2014-05-30
  • View(s):11
  • Download(s):0
  • Point(s): 1
			/*
* Copyright (C) 郝庆丰(qf.hao@hotmail.com)  2002. All rights reserved.
* Adhere to GPL (GNU Public License). 
*/

#include "LzwComp.h"
#include "Common.h"

#define   GENERAL
ENTRY string_tab[TAB_SIZE];
extern UINT  currentpos;
extern BYTE  outputbuf[];
extern int   oupindex,tempcode;

#define LZW_DEBUG
int main(int argc , char *argv[])
{

	//	register int infp , outfp;
	UINT prevcode , c , localcode ,count = 4096 - INIT_SIZE , 
		total = 0  ;
	//	char ch;
	register FILE  *infp , *outfp;
#ifndef  LZW_DEBUG
	if(argc < 3)
	{

		printf("Usage: lzwcom3   srcfilename   compfilename!");
		return -1;
	
}

	if(NULL == (infp = fopen(argv[1], "rb" )) ) 
	{

		printf("Cant open %s\n", argv[1]);
		return -1;
	
}
	if ( NULL == (outfp = fopen(argv[2],"wb+")) ) 
	{

		printf("Cant create %s\n",*argv);
		return -1;
	
}
#else
	if(-1 == (infp = fopen("g:\\lzw\\debug\\tmp.bin", "rb")) ) 
	{

		printf("Cant open %s\n", argv[1]);
		return 0;
	
}
	if(-1 == (outfp = fopen("g:\\lzw\\debug\\tmp.lzw", "wb+" )) ) 
	{

		printf("Cant open %s\n", argv[1]);
		return 0;
	
}
#endif

	putcode(outfp, CC);
	InitTable();
	c = readc(infp);
	prevcode = QueryTable(NO_PREV , c);
	++total;
	while(UEOF != (c = readc(infp)))
	{

		++total;
		//		ch = c;
		//    if(ch == 0x0D || ch== 0x0A)
		//		printf("enter ");

		if(NOT_FIND!=(localcode = QueryTable(prevcode , c)))
		{

			prevcode = localcode;
			continue;
		
}
		//	printf("prev code:
...
...
(Please download the complete source code to view)
			
...
Expand> <Close

Want complete source code? Download it here

Point(s): 1

Download
0 lines left, continue to read
Sponsored links

File list

Tips: You can preview the content of files by clicking file names^_^
Name Size Date
LzwComp.c2.16 kB2014-05-19|18:11
...
Sponsored links

LzwComp.c (1.08 kB)

Need 1 point
Your Point(s)

Your Point isn't enough.

Get point immediately by PayPal

More(Debit card / Credit card / PayPal Credit / Online Banking)

Submit your source codes. Get more point

LOGIN

Don't have an account? Register now
Need any help?
Mail to: support@codeforge.com

切换到中文版?

CodeForge Chinese Version
CodeForge English Version

Where are you going?

^_^"Oops ...

Sorry!This guy is mysterious, its blog hasn't been opened, try another, please!
OK

Warm tip!

CodeForge to FavoriteFavorite by Ctrl+D