comparison decode.cpp @ 6:aac9a23bd027

pretty print the c++ files yeah
author Paper <Paper@BIGMAC>
date Mon, 04 Jan 2021 14:22:32 -0500
parents 05978f04869b
children
comparison
equal deleted inserted replaced
5:9241ce1e5abe 6:aac9a23bd027
2 #include <curl/curl.h> 2 #include <curl/curl.h>
3 #include <iostream> 3 #include <iostream>
4 #include <string.h> 4 #include <string.h>
5 #include <fstream> 5 #include <fstream>
6 6
7 int main(int argc, char *argv[]){ 7 int main(int argc, char * argv[]) {
8 if(argc != 3){ 8 if (argc != 3) {
9 std::cout << "usage: " << argv[0] << " <input> <output>"; 9 std::cout << "usage: " << argv[0] << " <input> <output>";
10 return 0; 10 return 0;
11 } 11 }
12 std::string encoded; 12 std::string encoded;
13 CURL *curl = curl_easy_init(); 13 CURL * curl = curl_easy_init();
14 char somedata[256]; 14 char somedata[256];
15 std::ifstream in(argv[1], std::ios::in | std::ios::binary); 15 std::ifstream in (argv[1], std::ios:: in | std::ios::binary);
16 if (in) 16 if (in) {
17 { 17 in .seekg(0, std::ios::end);
18 in.seekg(0, std::ios::end); 18 encoded.resize( in .tellg()); in .seekg(0, std::ios::beg); in .read( & encoded[0], encoded.size()); in .close();
19 encoded.resize(in.tellg()); 19 }
20 in.seekg(0, std::ios::beg); 20 int outlength;
21 in.read(&encoded[0], encoded.size()); 21 char * cres = curl_easy_unescape(curl, encoded.c_str(), encoded.length(), & outlength);
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); 22 std::string res(cres, cres + outlength);
27 curl_free(cres); 23 curl_free(cres);
28 curl_easy_cleanup(curl); 24 curl_easy_cleanup(curl);
29 std::ofstream myfile2; 25 std::ofstream myfile2;
30 myfile2.open(argv[2]); 26 myfile2.open(argv[2]);
31 myfile2 << res; 27 myfile2 << res;
32 myfile2.close(); 28 myfile2.close();
33 return 0; 29 return 0;
34 } 30 }