|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
我感觉可以顶到50楼,出乎意料的是大家居然纷纷写出自己的博文,还被编辑做成了专题,置于首页头条。{ThisisinterfaceofC++code.
C++sourcecodenotincludedtothisarchive.
LookREADME.TXTfileformoreinformation.}
#ifndef__CODING_H__
#define__CODING_H__
#ifndefcoding_impex
#definecoding_impex__declspec(dllimport)
#endif
classcoding_impexavlDecode
{
public:
~avlDecode();
avlDecode();
virtualintReadBuf
(void*buf,
unsignedmaxLen,
unsigned&rdlen
)=0;
intGet(void*buf,unsignedmaxLen);
intGet(void*buf,unsignedmaxLen,unsigned&rdLen)
{return((int)(rdLen=Get(buf,maxLen))<0)?rdLen:0;
}
voidReset();
private:
?????????privatepartnotincluded???????????????????
};
classcoding_impexavlEncode
{
public:
~avlEncode();
avlEncode();
virtualintWriteBuf
(void*buf,
unsignedlen
)=0;
intPut(void*buf,unsignedn);
voidReset();
private:
??????????Privatepartnoticluded?????????????
};
#endif//__CODING_H__
///encode.pas
{$M8192,120000,120000}
usesavlcodes;
constBUFSIZE=60000;
varp:pointer;
f,f1:file;
s:string;
buf:pointer;
num:word;
{$F+}
FunctionWriteToFile(varbuf;n:integer):integer;
varnum:word;
Begin
BlockWrite(f1,buf,n,num);
End;
{$F-}
Begin
ifnotGetMemorythen
Begin
WriteLn(NotenoughmemoryinHEAPtocompressfile.);
halt;
End;
s:=paramstr(1);
SetEncodeOutBuffer(@WriteToFile);
assign(f,s);
{$I-}
ifsthenReset(f,1);
{$I+}
if(IoResult0)or(s=)then
Begin
WriteLn;
WriteLn(TheauthorofthisTurboPascalprogramandoriginalC++codeis);
WriteLn(AlexanderLarkin(translatedtoTurboPascalfromC++on27/09/1999));
WriteLn;
WriteLn(E-mail:avlarkin@writeme.com);
WriteLn(Internet:http://www.geocities.com/SiliconValley/6235/tpdl.htm);
WriteLn;
WriteLn(Usage:encode.exeInFileOutFile[password]);
WriteLn;
FreeMemory;
halt;
End;
s:=paramstr(2);
Assign(f1,s);
{$I-}
ifsthenReWrite(f1,1);
{$I+}
if(IoResult0)or(s=)then
Begin
Close(f);
WriteLn(Cannotcreatefindfile+s);
FreeMemory;
halt;
End;
SetPassword(ParamStr(3));
GetMem(buf,BUFSIZE);
repeat
BlockRead(f,buf^,BUFSIZE,num);
EncodePut(buf^,num);
untilnum<=0;
ifnum<0thenWriteLn(Cannotcompressfile.Youdosomethingwrong.);
EncodeReset;
Close(f);
Close(f1);
FreeMemory;
End.
///decode.pas
{$M8192,120000,120000}
usesavlcodes;
constBUFSIZE=60000;
varp:pointer;
f,f1:file;
s:string;
buf:pointer;
num:word;
{$F+}
FunctionReadFromFile(varbuf;n:integer;varrdlen:integer):integer;
Begin
BlockRead(f,buf,n,rdlen);
ReadFromFile:=0;
End;
{$F-}
Begin
ifnotGetMemorythen
Begin
WriteLn(NotenoughmemoryinHEAPtodecompressfile.);
halt;
End;
s:=paramstr(1);
SetDecodeInBuffer(@ReadFromFile);
assign(f,s);
{$I-}
ifsthenReset(f,1);
{$I+}
if(IoResult0)or(s=)then
Begin
WriteLn;
WriteLn(TheauthorofthisTurboPascalprogramandoriginalC++codeis);
WriteLn(AlexanderLarkin(translatedtoTurboPascalfromC++on27/09/1999));
WriteLn;
WriteLn(E-mail:avlarkin@writeme.com);
WriteLn(Internet:http://www.geocities.com/SiliconValley/6235/tpdl.htm);
WriteLn;
WriteLn(Usage:decode.exeInFileOutFile[password]);
WriteLn;
FreeMemory;
halt;
End;
s:=paramstr(2);
Assign(f1,s);
{$I-}
ifsthenReWrite(f1,1);
{$I+}
if(IoResult0)or(s=)then
Begin
Close(f);
WriteLn(Cannotcreatefile+s);
FreeMemory;
halt;
End;
GetMem(buf,BUFSIZE);
SetPassword(ParamStr(3));
repeat
num:=DecodeGet(buf^,BUFSIZE);
ifnum<65535thenBlockWrite(f1,buf^,num,num);
until(num=0)or(num=65535);
ifnum=65535thenWriteLn(Error!Datacorrupted.Cannotdecompressfile.);
Close(f);
Close(f1);
FreeMemory;
End.
[img=1border=0style=,1src=]http://www.ckuyun.com/[/img]
c语言的编译器,几乎是所有新平台都有的。因此从这点上看,c语言的程序,比其他任何语言更加容易跨平台。 |
|