一个C++及Delphi做的压缩程序

<script type="text/javascript"> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
<script type="text/javascript"> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
{ This is interface of C++ code.
  C++ source code not included to this archive.
  Look README.TXT file for more information. }

#ifndef __CODING_H__
#define __CODING_H__

#ifndef coding_impex
#define coding_impex __declspec(dllimport)
#endif

class coding_impex avlDecode
{
   public:
     ~avlDecode();
      avlDecode();

      virtual int ReadBuf            
                  ( void     *buf,   
                    unsigned  maxLen,
                    unsigned &rdlen  
                  ) = 0;             

      int  Get(void *buf, unsigned  maxLen);
      int  Get(void *buf, unsigned  maxLen, unsigned &rdLen)
      {  return ((int)(rdLen = Get(buf, maxLen)) < 0)? rdLen :0 ;
      }

      void Reset();

   private:

   ????????? private part not included ???????????????????

};


class coding_impex avlEncode
{
   public:
     ~avlEncode();
      avlEncode();

      virtual int WriteBuf           
                  ( void     *buf,   
                    unsigned  len    
                  ) = 0;             


      int  Put(void *buf, unsigned  n);
      void Reset();

   private:
  ?????????? Private part not icluded ?????????????

};

#endif //__CODING_H__


///encode.pas
{$M 8192,120000,120000}
uses avlcodes;

const BUFSIZE=60000;

var p: pointer;
    f,f1: file;
    s: string;
    buf: pointer;
    num: word;

{$F+}

Function WriteToFile(var buf; n: integer): integer;
var num: word;
Begin
BlockWrite(f1,buf,n,num);
End;

{$F-}

Begin
if not GetMemory then
  Begin
   WriteLn('Not enough memory in HEAP to compress file.');
   halt;
  End;
s:=paramstr(1);
SetEncodeOutBuffer(@WriteToFile);
assign(f,s);
{$I-}
  if s<>'' then Reset(f,1);
{$I+}
if (IoResult<>0) or (s='') then
  Begin
   WriteLn;
   WriteLn('The author of this Turbo Pascal program and original C++ code is');
   WriteLn('Alexander Larkin   ( translated to Turbo Pascal from C++ on 27/09/1999 )');
   WriteLn;
   WriteLn('E-mail:      avlarkin@writeme.com');
   WriteLn('Internet:    http://www.geocities.com/SiliconValley/6235/tpdl.htm');
   WriteLn;
   WriteLn('Usage: encode.exe InFile OutFile [password]');
   WriteLn;
   FreeMemory;
   halt;
  End;
s:=paramstr(2);
Assign(f1,s);
{$I-}
if s<>'' then ReWrite(f1,1);
{$I+}
if (IoResult<>0) or (s='') then
  Begin
   Close(f);
   WriteLn('Cannot create find file '+s);
   FreeMemory;
   halt;
  End;
SetPassword(ParamStr(3));
  GetMem(buf,BUFSIZE);
   repeat
    BlockRead(f,buf^,BUFSIZE,num);
    EncodePut(buf^,num);
   until num<=0;
  if num<0 then WriteLn('Cannot compress file. You do something wrong.');
EncodeReset;
Close(f);
Close(f1);
FreeMemory;
End.

///decode.pas
{$M 8192,120000,120000}
uses avlcodes;

const BUFSIZE=60000;

var p: pointer;
    f,f1: file;
    s: string;
    buf: pointer;
    num: word;

{$F+}

Function ReadFromFile(var buf; n: integer; var rdlen: integer): integer;
Begin
BlockRead(f,buf,n,rdlen);
ReadFromFile:=0;
End;

{$F-}

Begin
if not GetMemory then
  Begin
   WriteLn('Not enough memory in HEAP to decompress file.');
   halt;
  End;
s:=paramstr(1);
SetDecodeInBuffer(@ReadFromFile);
assign(f,s);
{$I-}
  if s<>'' then Reset(f,1);
{$I+}
if (IoResult<>0) or (s='') then
  Begin
   WriteLn;
   WriteLn('The author of this Turbo Pascal program and original C++ code is');
   WriteLn('Alexander Larkin   ( translated to Turbo Pascal from C++ on 27/09/1999 )');
   WriteLn;
   WriteLn('E-mail:      avlarkin@writeme.com');
   WriteLn('Internet:    http://www.geocities.com/SiliconValley/6235/tpdl.htm');
   WriteLn;
   WriteLn('Usage: decode.exe InFile OutFile [password]');
   WriteLn;
   FreeMemory;
   halt;
  End;
s:=paramstr(2);
Assign(f1,s);
{$I-}
if s<>'' then ReWrite(f1,1);
{$I+}
if (IoResult<>0) or (s='') then
  Begin
   Close(f);
   WriteLn('Cannot create file '+s);
   FreeMemory;
   halt;
  End;
  GetMem(buf,BUFSIZE);
  SetPassword(ParamStr(3));
   repeat
    num:=DecodeGet(buf^,BUFSIZE);
    if num<65535 then BlockWrite(f1,buf^,num,num);
   until (num=0) or (num=65535);
if num=65535 then WriteLn('Error! Data corrupted. Cannot decompress file.');
Close(f);
Close(f1);
FreeMemory;
End.

seover="window.status='正文-- 一个C++及 Delphi做的 压缩程序';return true">
<script type="text/javascript"> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
<script type="text/javascript"> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值