mirror of
https://github.com/benapetr/stikkit.git
synced 2025-04-25 20:41:20 -05:00
first working version
This commit is contained in:
parent
84f3fce887
commit
f3291555ca
@ -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
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user