Added: getting paste content.
This commit is contained in:
parent
9d7a93c622
commit
f9b52a5ba3
3 changed files with 40 additions and 4 deletions
32
func.cpp
32
func.cpp
|
@ -114,7 +114,7 @@ void showVersion()
|
||||||
<< "Error report: <error-report@tobast.fr>" << std::endl << std::endl;
|
<< "Error report: <error-report@tobast.fr>" << std::endl << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
CurlPost* preparePostRequest(const unsigned& flags, ParameterRead& pr)
|
CurlPost* preparePostRequest(const unsigned& flags, ParameterRead& pr, std::string pasteContent)
|
||||||
{
|
{
|
||||||
CurlPost* request=new CurlPost(PASTEBIN_SUBMIT_URL);
|
CurlPost* request=new CurlPost(PASTEBIN_SUBMIT_URL);
|
||||||
|
|
||||||
|
@ -158,6 +158,7 @@ CurlPost* preparePostRequest(const unsigned& flags, ParameterRead& pr)
|
||||||
request->setPostData("api_user_key", usercode);
|
request->setPostData("api_user_key", usercode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
request->setPostData("api_paste_code", pasteContent);
|
||||||
request->setPostData("api_dev_key", DEVELOPPER_CODE);
|
request->setPostData("api_dev_key", DEVELOPPER_CODE);
|
||||||
request->setPostData("api_option", "paste");
|
request->setPostData("api_option", "paste");
|
||||||
|
|
||||||
|
@ -170,3 +171,32 @@ std::string getUserCode()
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string getPasteContent()
|
||||||
|
{
|
||||||
|
std::string outstr;
|
||||||
|
|
||||||
|
if(!std::cin.eof())
|
||||||
|
{
|
||||||
|
while(1)
|
||||||
|
{
|
||||||
|
char c=std::cin.get();
|
||||||
|
if(std::cin.eof())
|
||||||
|
break;
|
||||||
|
outstr+=c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
while(1)
|
||||||
|
{
|
||||||
|
std::string tmp;
|
||||||
|
std::cin >> tmp;
|
||||||
|
outstr+=tmp;
|
||||||
|
if(tmp.find(-1) != std::string::npos) // found a ^D
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return outstr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
3
func.h
3
func.h
|
@ -46,9 +46,10 @@ void showLicence();
|
||||||
void showHelp();
|
void showHelp();
|
||||||
void showVersion();
|
void showVersion();
|
||||||
|
|
||||||
CurlPost* preparePostRequest(const unsigned& flags, ParameterRead& pr);
|
CurlPost* preparePostRequest(const unsigned& flags, ParameterRead& pr, std::string pasteContent);
|
||||||
|
|
||||||
std::string getUserCode();
|
std::string getUserCode();
|
||||||
|
std::string getPasteContent();
|
||||||
|
|
||||||
#endif//DEF_FUNCTION
|
#endif//DEF_FUNCTION
|
||||||
|
|
||||||
|
|
9
main.cpp
9
main.cpp
|
@ -61,8 +61,11 @@ int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
// Here we start real stuff!
|
// Here we start real stuff!
|
||||||
CurlPost::init();
|
CurlPost::init();
|
||||||
|
|
||||||
|
CurlPost* request=preparePostRequest(parameterFlags, pr, getPasteContent());
|
||||||
|
|
||||||
|
std::cout << "Submitting paste..." << std::endl;
|
||||||
|
|
||||||
CurlPost* request=preparePostRequest(parameterFlags, pr);
|
|
||||||
std::string result=request->execute();
|
std::string result=request->execute();
|
||||||
delete request;
|
delete request;
|
||||||
|
|
||||||
|
@ -80,7 +83,9 @@ int main(int argc, char** argv)
|
||||||
CurlPost::clean();
|
CurlPost::clean();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(...) {}
|
catch(...) {
|
||||||
|
std::cerr << "Exception catched. Program is terminating." << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue