lzo的正确c语言代码,求助,看不懂这个lzo压缩文件程序

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

我知道是压缩文件,但是不知道它具体实现了什么功能(完整的),有没有人能看明白?

大概说个流程就好,具体功能怎么实现,我可以自己再琢磨,谢谢大佬!

以下为源程序:

// tests1932k.cpp : 定义控制台应用程序的入口点。

//#include "stdafx.h"#include "minilzo.h"unsigned char inputdata[32 * 1024];

unsigned long inputdata_len = 32 * 1024;unsigned char outputdata[32 * 1024];

unsigned long outputdata_len = 0;#define HEAP_ALLOC(var,size) \

lzo_align_t __LZO_MMODEL var [ ((size) + (sizeof(lzo_align_t) - 1)) / sizeof(lzo_align_t) ]static HEAP_ALLOC(wrkmem, LZO1X_1_MEM_COMPRESS);void outputs19file(const unsigned long address,const unsigned char *data)

{

for (int tempaddr = address; tempaddr < 32; tempaddr++)

{ }

}int main(int argc, char *argv[])

{

FILE *inputfile = NULL,*outputfile = NULL;

if (lzo_init() != LZO_E_OK)

{

printf("internal error - lzo_init() failed !!!\n");

printf("(this usually indicates a compiler bug - try recompiling\nwithout optimizations, and enable '-DLZO_DEBUG' for diagnostics)\n");

return 3;

}

if (argc < 3)

{

inputfile = fopen("standalone_tcflash.txt","r");

outputfile = fopen("output.bin","wb");

}

else

{

inputfile = fopen(argv[1],"r");

outputfile = fopen(argv[2],"wb");

}

if (!((NULL != inputfile) && (NULL != outputfile)))

{

return -1;

}

else

{

for (unsigned long address = 0;address < 0x10000000;address+= 32768)

{

int ret = 0,i = 0;

for (; i < 32768; i++)

{

if(1 == fscanf(inputfile,"%X",inputdata + i))

{

}

else

{

break;

}

}

for (int temp = i; temp < 32768; temp++)

{

inputdata[temp] = 0xFF;

}

ret = lzo1x_1_compress(inputdata,32768,outputdata,&outputdata_len,wrkmem);

for (int temp = outputdata_len; temp < 32768; temp++)

{

outputdata[temp] = 0xFF;

}

if(0 == ret)

{

fwrite(outputdata,1,outputdata_len,outputfile);

}

if (i != 32768)

{

break;

}

}

fclose(inputfile);

fclose(outputfile);

}}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值