简体   繁体   中英

cURL c++ and gunzip

I am working on a program that reads the headers from a curl perform and searches for 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM