mirror of
https://github.com/benapetr/stikkit.git
synced 2025-04-26 04:51:09 -05:00
first working version
This commit is contained in:
parent
84f3fce887
commit
f3291555ca
@ -15,6 +15,15 @@
|
|||||||
#include "terminalparser.hpp"
|
#include "terminalparser.hpp"
|
||||||
#include "syslog.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[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
Stikkit::TerminalParser *t = new Stikkit::TerminalParser(argc, argv);
|
Stikkit::TerminalParser *t = new Stikkit::TerminalParser(argc, argv);
|
||||||
@ -43,10 +52,12 @@ int main(int argc, char *argv[])
|
|||||||
curl = curl_easy_init();
|
curl = curl_easy_init();
|
||||||
if(curl)
|
if(curl)
|
||||||
{
|
{
|
||||||
|
readBuffer.clear();
|
||||||
string post = "text=";
|
string post = "text=";
|
||||||
post += curl_easy_escape(curl, Stikkit::Configuration::Source.c_str(), Stikkit::Configuration::Source.length());
|
post += curl_easy_escape(curl, Stikkit::Configuration::Source.c_str(), Stikkit::Configuration::Source.length());
|
||||||
post += "&name=";
|
post += "&name=";
|
||||||
post += curl_easy_escape(curl, Stikkit::Configuration::Author.c_str(), Stikkit::Configuration::Author.length());
|
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_URL, Stikkit::Configuration::URL.c_str());
|
||||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, post.c_str());
|
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, post.c_str());
|
||||||
|
|
||||||
@ -55,7 +66,7 @@ int main(int argc, char *argv[])
|
|||||||
/* Check for errors */
|
/* Check for errors */
|
||||||
if(res != CURLE_OK)
|
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);
|
curl_easy_cleanup(curl);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user