You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-29 08:21:15 +03:00
clang format apply
This commit is contained in:
@ -16,9 +16,9 @@
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
/*****************************************************************************
|
||||
* $Id: main.cpp 2101 2013-01-21 14:12:52Z rdempsey $
|
||||
*
|
||||
*****************************************************************************/
|
||||
* $Id: main.cpp 2101 2013-01-21 14:12:52Z rdempsey $
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#include <iostream>
|
||||
#include <cassert>
|
||||
@ -35,134 +35,124 @@ using namespace config;
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
void usage(const string& pname)
|
||||
{
|
||||
cout << "usage: " << pname << " [-vh] [-c config_file] section param" << endl <<
|
||||
" Displays configuration variable param from section section." << endl <<
|
||||
" -c config_file use config file config_file" << endl <<
|
||||
" -a display all configuration values" << endl <<
|
||||
" -i display all configuration values in .ini-file format (implies -a)" << endl <<
|
||||
" -v display verbose information" << endl <<
|
||||
" -h display this help text" << endl;
|
||||
cout << "usage: " << pname << " [-vh] [-c config_file] section param" << endl
|
||||
<< " Displays configuration variable param from section section." << endl
|
||||
<< " -c config_file use config file config_file" << endl
|
||||
<< " -a display all configuration values" << endl
|
||||
<< " -i display all configuration values in .ini-file format (implies -a)" << endl
|
||||
<< " -v display verbose information" << endl
|
||||
<< " -h display this help text" << endl;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
int c;
|
||||
string pname(argv[0]);
|
||||
bool vflg = false;
|
||||
string configFile;
|
||||
bool aflg = false;
|
||||
bool iflg = false;
|
||||
int c;
|
||||
string pname(argv[0]);
|
||||
bool vflg = false;
|
||||
string configFile;
|
||||
bool aflg = false;
|
||||
bool iflg = false;
|
||||
|
||||
opterr = 0;
|
||||
opterr = 0;
|
||||
|
||||
while ((c = getopt(argc, argv, "c:vaih")) != EOF)
|
||||
switch (c)
|
||||
{
|
||||
case 'v':
|
||||
vflg = true;
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
configFile = optarg;
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
aflg = true;
|
||||
break;
|
||||
|
||||
case 'i':
|
||||
iflg = aflg = true;
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
case '?':
|
||||
default:
|
||||
usage(pname);
|
||||
return (c == 'h' ? 0 : 1);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!aflg && ( (argc - optind) < 2 ))
|
||||
while ((c = getopt(argc, argv, "c:vaih")) != EOF)
|
||||
switch (c)
|
||||
{
|
||||
case 'v': vflg = true; break;
|
||||
|
||||
case 'c': configFile = optarg; break;
|
||||
|
||||
case 'a': aflg = true; break;
|
||||
|
||||
case 'i': iflg = aflg = true; break;
|
||||
|
||||
case 'h':
|
||||
case '?':
|
||||
default:
|
||||
usage(pname);
|
||||
return 1;
|
||||
return (c == 'h' ? 0 : 1);
|
||||
break;
|
||||
}
|
||||
|
||||
try
|
||||
if (!aflg && ((argc - optind) < 2))
|
||||
{
|
||||
usage(pname);
|
||||
return 1;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
openlog("mcsGetConfig", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_USER);
|
||||
Config* cf;
|
||||
|
||||
if (configFile.length() > 0)
|
||||
cf = Config::makeConfig(configFile);
|
||||
else
|
||||
cf = Config::makeConfig();
|
||||
|
||||
if (vflg)
|
||||
{
|
||||
openlog("mcsGetConfig", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_USER);
|
||||
Config* cf;
|
||||
cout << "Using config file: " << cf->configFile() << endl;
|
||||
}
|
||||
|
||||
if (configFile.length() > 0)
|
||||
cf = Config::makeConfig(configFile);
|
||||
else
|
||||
cf = Config::makeConfig();
|
||||
if (aflg)
|
||||
{
|
||||
vector<string> secs;
|
||||
vector<string> parms;
|
||||
secs = cf->enumConfig();
|
||||
vector<string>::iterator siter;
|
||||
vector<string>::iterator send;
|
||||
vector<string>::iterator piter;
|
||||
vector<string>::iterator pend;
|
||||
siter = secs.begin();
|
||||
send = secs.end();
|
||||
|
||||
if (vflg)
|
||||
while (siter != send)
|
||||
{
|
||||
if (iflg)
|
||||
cout << '[' << *siter << ']' << endl;
|
||||
|
||||
parms = cf->enumSection(*siter);
|
||||
piter = parms.begin();
|
||||
pend = parms.end();
|
||||
|
||||
while (piter != pend)
|
||||
{
|
||||
cout << "Using config file: " << cf->configFile() << endl;
|
||||
if (iflg)
|
||||
cout << *piter << " = " << cf->getConfig(*siter, *piter) << endl;
|
||||
else
|
||||
cout << *siter << '.' << *piter << " = " << cf->getConfig(*siter, *piter) << endl;
|
||||
|
||||
++piter;
|
||||
}
|
||||
|
||||
if (aflg)
|
||||
{
|
||||
vector<string> secs;
|
||||
vector<string> parms;
|
||||
secs = cf->enumConfig();
|
||||
vector<string>::iterator siter;
|
||||
vector<string>::iterator send;
|
||||
vector<string>::iterator piter;
|
||||
vector<string>::iterator pend;
|
||||
siter = secs.begin();
|
||||
send = secs.end();
|
||||
++siter;
|
||||
|
||||
while (siter != send)
|
||||
{
|
||||
if (iflg)
|
||||
cout << '[' << *siter << ']' << endl;
|
||||
if (iflg)
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
parms = cf->enumSection(*siter);
|
||||
piter = parms.begin();
|
||||
pend = parms.end();
|
||||
|
||||
while (piter != pend)
|
||||
{
|
||||
if (iflg)
|
||||
cout << *piter << " = " << cf->getConfig(*siter, *piter) << endl;
|
||||
else
|
||||
cout << *siter << '.' << *piter << " = " <<
|
||||
cf->getConfig(*siter, *piter) << endl;
|
||||
|
||||
++piter;
|
||||
}
|
||||
|
||||
++siter;
|
||||
|
||||
if (iflg)
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
cout << cf->getConfig(argv[optind + 0], argv[optind + 1]) << endl;
|
||||
closelog();
|
||||
}
|
||||
catch (exception& e)
|
||||
{
|
||||
syslog(LOG_ERR, "Exception in mcsGetConfig for %s %s : %s", argv[optind + 0], argv[optind + 1], e.what());
|
||||
closelog();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
syslog(LOG_ERR, "Exception in mcsGetConfig for %s %s : Unknown exception", argv[optind + 0], argv[optind + 1]);
|
||||
closelog();
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
cout << cf->getConfig(argv[optind + 0], argv[optind + 1]) << endl;
|
||||
closelog();
|
||||
}
|
||||
catch (exception& e)
|
||||
{
|
||||
syslog(LOG_ERR, "Exception in mcsGetConfig for %s %s : %s", argv[optind + 0], argv[optind + 1], e.what());
|
||||
closelog();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
syslog(LOG_ERR, "Exception in mcsGetConfig for %s %s : Unknown exception", argv[optind + 0],
|
||||
argv[optind + 1]);
|
||||
closelog();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user