122 lines
3.7 KiB
C++
122 lines
3.7 KiB
C++
|
||
/*
|
||
* PROGRAM:
|
||
* Command-line pastebin
|
||
*
|
||
* AUTHOR:
|
||
* Théophile BASTIAN (a.k.a. Tobast)
|
||
*
|
||
* CONTACT & WEBSITE:
|
||
* http://tobast.fr/ (contact feature included)
|
||
* error-report@tobast.fr (error reporting only)
|
||
*
|
||
* SHORT DESCRIPTION:
|
||
* See first license line.
|
||
*
|
||
* LICENSE:
|
||
* "Command-line pastebin" is a software designed to submit a "paste" on http://pastebin.com/ using a command-line tool
|
||
* Copyright (C) 2011 Théophile BASTIAN
|
||
*
|
||
* This program is free software: you can redistribute it and/or modify
|
||
* it under the terms of the GNU General Public License as published by
|
||
* the Free Software Foundation, either version 3 of the License, or
|
||
* (at your option) any later version.
|
||
*
|
||
* This program is distributed in the hope that it will be useful,
|
||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
* GNU General Public License for more details.
|
||
*
|
||
* You should have received a copy of the GNU General Public License
|
||
* along with this program. If not, see http://www.gnu.org/licenses/gpl.txt.
|
||
*/
|
||
|
||
#include "func.h"
|
||
|
||
bool initParameterRead(ParameterRead& pr, unsigned& flags)
|
||
{
|
||
pr.addValueParam("n");
|
||
pr.addValueParam("name");
|
||
pr.addValueParam("s");
|
||
pr.addValueParam("syntax");
|
||
pr.addValueParam("e");
|
||
pr.addValueParam("expire");
|
||
|
||
pr.execute();
|
||
|
||
if(!checkParameterRead(pr, flags))
|
||
return false;
|
||
return true;
|
||
}
|
||
|
||
bool checkParameterRead(ParameterRead& pr, unsigned& flags)
|
||
{
|
||
try {
|
||
if(pr.isSet("licence"))
|
||
{
|
||
flags=P_LICENCE;
|
||
return true;
|
||
}
|
||
if(pr.isSet("h") || pr.isSet("?") || pr.isSet("help"))
|
||
{
|
||
flags=P_HELP;
|
||
return true;
|
||
}
|
||
if(pr.isSet("v") || pr.isSet("version"))
|
||
{
|
||
flags=P_VERSION;
|
||
return true;
|
||
}
|
||
if((pr.isSet("n") && pr.isValueSet("n", true)) || (pr.isSet("name") && pr.isValueSet("name", true)))
|
||
flags+=P_NAME;
|
||
if((pr.isSet("s") && pr.isValueSet("s", true)) || (pr.isSet("syntax") && pr.isValueSet("syntax", true)))
|
||
flags+=P_SYNTAX;
|
||
if((pr.isSet("e") && pr.isValueSet("e", true)) || (pr.isSet("expire") && pr.isValueSet("expire", true)))
|
||
flags+=P_EXPIRE;
|
||
if(pr.isSet("p") || pr.isSet("private"))
|
||
flags+=P_PRIVATE;
|
||
if(pr.isSet("g") || pr.isSet("guest"))
|
||
flags+=P_PRIVATE;
|
||
}
|
||
catch(const int& e) {
|
||
return false;
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
void showLicence()
|
||
{
|
||
std::cout << std::endl <<
|
||
"Copyright (C) 2011 Théophile BASTIAN (aka. Tobast) " << std::endl <<
|
||
"This program is free software: you can redistribute it and/or modify " << std::endl <<
|
||
"it under the terms of the GNU General Public License as published by " << std::endl <<
|
||
"the Free Software Foundation, either version 3 of the License, or " << std::endl <<
|
||
"(at your option) any later version. " << std::endl <<
|
||
std::endl <<
|
||
"This program is distributed in the hope that it will be useful, " << std::endl <<
|
||
"but WITHOUT ANY WARRANTY; without even the implied warranty of " << std::endl <<
|
||
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the " << std::endl <<
|
||
"GNU General Public License for more details. " << std::endl <<
|
||
std::endl <<
|
||
"You should have received a copy of the GNU General Public License " << std::endl <<
|
||
"along with this program. If not, see http://www.gnu.org/licenses/gpl.txt." << std::endl << std::endl;
|
||
}
|
||
void showHelp()
|
||
{
|
||
std::cout << MANPAGE_SHORT << std::endl;
|
||
}
|
||
void showVersion()
|
||
{
|
||
std::cout << std::endl
|
||
<< "pastebincl by BASTIAN Théophile (aka Tobast) v" << SOFT_VERSION << std::endl
|
||
<< "Contact: <contact@tobast.fr> or contact feature at http://tobast.fr/" << std::endl
|
||
<< "Error report: <error-report@tobast.fr>" << std::endl << std::endl;
|
||
}
|
||
|
||
CurlPost* preparePostRequest(const unsigned& flags, const ParameterRead& pr)
|
||
{
|
||
// TODO!
|
||
}
|
||
|