Linux中国 Linux中国门户站!
设为主页 设为主页
收藏本站 收藏本站
 
当前位置 :首页 ->编程语言 ->ASP.NET ->正文

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

来源:Linuxdby.com 作者:Webmaster 时间:2007-04-28 点击: [收藏] [投稿]
{ 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);

 如果您对本文有任何疑问或者建议,请到讨论区发表您的意见: >> 论坛入口 <<



上一篇:在分发包里加入两个Merge Moudle,见内   下一篇:ACCESS2000数据库文件密码的提取(源程序c++builder5)(推荐大家转换成C#版本)

文章评论】 【收藏本文】 【推荐好友】 【打印本文】 【我要投稿】 【论坛讨论
更多相关文章
Power by linux-cn.com 粤ICP备05006655号