开发者

cURL c++ and gunzip

I am working on a program that reads the headers from a curl perform and searches fo开发者_运维技巧r a particular header and if found, gunzip the content part and search for another string in the content. i need to implement the last part. rest is done. is there a way to unzip the contents from inside the c++ program and save the result to another string and search that string?

code snippets would be good. thanks.


Use Boost Iostreams. If buf is a string containing the gzip'd data,

namespace io = boost::iostreams;

io::filtering_istream gunzip;
gunzip.push(io::gzip_decompressor());
gunzip.push(std::istringstream(buf));

then read from gunzip.


Apart from implementing gunzip yourself, use an execv() call to the actual gunzip program and return the output to stdout (which is then passed to your program). Also, string searching is probably best done using the Knuth–Morris–Pratt algorithm.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜