diff --git a/stikkit/main.cpp b/stikkit/main.cpp index c31b3d4..91c5c6d 100644 --- a/stikkit/main.cpp +++ b/stikkit/main.cpp @@ -15,6 +15,15 @@ #include "terminalparser.hpp" #include "syslog.hpp" +static std::string readBuffer; + +static size_t WriteCallback(void *contents, size_t size, size_t nmemb) +{ + size_t realsize = size * nmemb; + readBuffer.append((const char*)contents, realsize); + return realsize; +} + int main(int argc, char *argv[]) { Stikkit::TerminalParser *t = new Stikkit::TerminalParser(argc, argv); @@ -43,10 +52,12 @@ int main(int argc, char *argv[]) curl = curl_easy_init(); if(curl) { + readBuffer.clear(); string post = "text="; post += curl_easy_escape(curl, Stikkit::Configuration::Source.c_str(), Stikkit::Configuration::Source.length()); post += "&name="; post += curl_easy_escape(curl, Stikkit::Configuration::Author.c_str(), Stikkit::Configuration::Author.length()); + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback); curl_easy_setopt(curl, CURLOPT_URL, Stikkit::Configuration::URL.c_str()); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, post.c_str()); @@ -54,8 +65,8 @@ int main(int argc, char *argv[]) res = curl_easy_perform(curl); /* Check for errors */ if(res != CURLE_OK) - cerr << "curl_easy_perform() failed: " << curl_easy_strerror(res) << endl; - + cerr << "curl_easy_perform() failed: " << curl_easy_strerror(res) << endl; + cout << "Successfully pastebined to: " << readBuffer; curl_easy_cleanup(curl); } else {