@@ -23,7 +23,6 @@ size_t write_data ( void *ptr, size_t size, size_t nmemb, void *stream ); // wri
23
23
bool Curl::DownloadFile ( std::string fileURL, std::string filePath )
24
24
{
25
25
CURL *curl; // initialize curl
26
- CURLcode res; // variable to store curl result
27
26
curl = curl_easy_init (); // initialize curl_easy
28
27
if ( curl ) // if curl was initialized
29
28
{
@@ -35,20 +34,22 @@ bool Curl::DownloadFile ( std::string fileURL, std::string filePath )
35
34
curl_easy_setopt ( curl, CURLOPT_WRITEDATA, fp ); // set the file path
36
35
curl_easy_setopt ( curl, CURLOPT_NOPROGRESS, FALSE ); // we want progress
37
36
curl_easy_setopt ( curl, CURLOPT_PROGRESSFUNCTION, progress_callback ); // set the progress callback function
38
- res = curl_easy_perform ( curl ); // perform; store result into res
37
+ CURLcode res = curl_easy_perform ( curl ); // perform; store result into res
39
38
curl_easy_cleanup ( curl ); // clean up
40
39
fclose ( fp ); // close the file
41
- }
42
- if ( !res ) // if we were successful
40
+
41
+ if ( !res ) // if we were successful
43
42
return true ;
44
- else // failure
43
+ else // failure
44
+ return false ;
45
+ }
46
+ else // failure to initialize CURL
45
47
return false ;
46
48
}
47
49
48
50
std::string Curl::CreatePasteBin ( std::string filePath, std::string pasteName )
49
51
{
50
52
CURL *curl; // initialize curl
51
- CURLcode res; // variable to store curl result
52
53
curl = curl_easy_init (); // initialize curl_easy
53
54
54
55
std::string logText; // stores entire log file
@@ -92,17 +93,22 @@ std::string Curl::CreatePasteBin ( std::string filePath, std::string pasteName )
92
93
curl_easy_setopt ( curl, CURLOPT_NOPROGRESS, FALSE ); // we want progress
93
94
curl_easy_setopt ( curl, CURLOPT_PROGRESSFUNCTION, progress_callback ); // set the progress callback function
94
95
curl_easy_setopt ( curl, CURLOPT_WRITEFUNCTION, write_data ); // set the write function
95
- res = curl_easy_perform ( curl ); // perform; store result into res
96
+ CURLcode res = curl_easy_perform ( curl ); // perform; store result into res
96
97
curl_easy_cleanup ( curl ); // clean up
97
- }
98
- if ( !res ) // if we were successful
99
- {
100
98
101
- return response;
99
+ if ( !res ) // if we were successful
100
+ {
101
+
102
+ return response;
103
+ }
104
+ else // failure
105
+ {
106
+ return " Failed to upload to Pastebin." ;
107
+ }
102
108
}
103
- else // failure
109
+ else
104
110
{
105
- return " Failed to upload to Pastebin ." ;
111
+ return " Failed to initialize CURL ." ;
106
112
}
107
113
}
108
114
0 commit comments