Mercurial > codedump
comparison decode.cpp @ 1:05978f04869b
Add files via upload
committer: GitHub <noreply@github.com>
author | Paper <37962225+mrpapersonic@users.noreply.github.com> |
---|---|
date | Mon, 04 Jan 2021 13:52:42 -0500 |
parents | |
children | aac9a23bd027 |
comparison
equal
deleted
inserted
replaced
0:bfa16fc2d0a5 | 1:05978f04869b |
---|---|
1 // requires libcurl | |
2 #include <curl/curl.h> | |
3 #include <iostream> | |
4 #include <string.h> | |
5 #include <fstream> | |
6 | |
7 int main(int argc, char *argv[]){ | |
8 if(argc != 3){ | |
9 std::cout << "usage: " << argv[0] << " <input> <output>"; | |
10 return 0; | |
11 } | |
12 std::string encoded; | |
13 CURL *curl = curl_easy_init(); | |
14 char somedata[256]; | |
15 std::ifstream in(argv[1], std::ios::in | std::ios::binary); | |
16 if (in) | |
17 { | |
18 in.seekg(0, std::ios::end); | |
19 encoded.resize(in.tellg()); | |
20 in.seekg(0, std::ios::beg); | |
21 in.read(&encoded[0], encoded.size()); | |
22 in.close(); | |
23 } | |
24 int outlength; | |
25 char *cres = curl_easy_unescape(curl, encoded.c_str(), encoded.length(), &outlength); | |
26 std::string res(cres, cres + outlength); | |
27 curl_free(cres); | |
28 curl_easy_cleanup(curl); | |
29 std::ofstream myfile2; | |
30 myfile2.open(argv[2]); | |
31 myfile2 << res; | |
32 myfile2.close(); | |
33 return 0; | |
34 } |