support wildcard filtering in getConfNames() + implement config checking function in test driver
This commit is contained in:
parent
8ae29d219b
commit
684da16948
@ -934,13 +934,15 @@ using namespace std;
|
|||||||
|
|
||||||
static char *thisprog;
|
static char *thisprog;
|
||||||
|
|
||||||
static char usage [] =
|
static char usage [] = "\n"
|
||||||
" \n\n"
|
"-c: check a few things in the configuration files\n"
|
||||||
|
"[-s subkey] -q param : query parameter value\n"
|
||||||
|
" : default: print parameters\n"
|
||||||
;
|
;
|
||||||
static void
|
static void
|
||||||
Usage(void)
|
Usage(void)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s: usage:\n%s [-s subkey] [-q param]", thisprog, usage);
|
fprintf(stderr, "%s: usage: %s\n", thisprog, usage);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -948,7 +950,7 @@ static int op_flags;
|
|||||||
#define OPT_MOINS 0x1
|
#define OPT_MOINS 0x1
|
||||||
#define OPT_s 0x2
|
#define OPT_s 0x2
|
||||||
#define OPT_q 0x4
|
#define OPT_q 0x4
|
||||||
|
#define OPT_c 0x8
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
string pname, skey;
|
string pname, skey;
|
||||||
@ -963,6 +965,7 @@ int main(int argc, char **argv)
|
|||||||
Usage();
|
Usage();
|
||||||
while (**argv)
|
while (**argv)
|
||||||
switch (*(*argv)++) {
|
switch (*(*argv)++) {
|
||||||
|
case 'c': op_flags |= OPT_c; break;
|
||||||
case 's': op_flags |= OPT_s; if (argc < 2) Usage();
|
case 's': op_flags |= OPT_s; if (argc < 2) Usage();
|
||||||
skey = *(++argv);
|
skey = *(++argv);
|
||||||
argc--;
|
argc--;
|
||||||
@ -994,8 +997,42 @@ int main(int argc, char **argv)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
printf("[%s] -> [%s]\n", pname.c_str(), value.c_str());
|
printf("[%s] -> [%s]\n", pname.c_str(), value.c_str());
|
||||||
|
} else if (op_flags & OPT_c) {
|
||||||
|
// Check that all known mime types have an icon and belong to
|
||||||
|
// some category
|
||||||
|
list<string> catnames;
|
||||||
|
config->getMimeCategories(catnames);
|
||||||
|
cout << "Categories: ";
|
||||||
|
set<string> allmtsfromcats;
|
||||||
|
for (list<string>::const_iterator it = catnames.begin();
|
||||||
|
it != catnames.end(); it++) {
|
||||||
|
cout << *it << " ";
|
||||||
|
}
|
||||||
|
cout << endl;
|
||||||
|
for (list<string>::const_iterator it = catnames.begin();
|
||||||
|
it != catnames.end(); it++) {
|
||||||
|
list<string> cts;
|
||||||
|
config->getMimeCatTypes(*it, cts);
|
||||||
|
for (list<string>::const_iterator it1 = cts.begin();
|
||||||
|
it1 != cts.end(); it1++) {
|
||||||
|
// Already in map -> duplicate
|
||||||
|
if (allmtsfromcats.find(*it1) != allmtsfromcats.end()) {
|
||||||
|
cout << "Duplicate: [" << *it1 << "]" << endl;
|
||||||
|
}
|
||||||
|
allmtsfromcats.insert(*it1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
list<string> mtypes = config->getAllMimeTypes();
|
||||||
|
for (list<string>::const_iterator it = mtypes.begin();
|
||||||
|
it != mtypes.end(); it++) {
|
||||||
|
if (allmtsfromcats.find(*it) == allmtsfromcats.end()) {
|
||||||
|
cout << "Not found in catgs: [" << *it << "]" << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
list<string> names = config->getConfNames("");
|
config->setKeyDir("");
|
||||||
|
list<string> names = config->getConfNames();
|
||||||
names.sort();
|
names.sort();
|
||||||
names.unique();
|
names.unique();
|
||||||
for (list<string>::iterator it = names.begin();
|
for (list<string>::iterator it = names.begin();
|
||||||
|
|||||||
@ -83,6 +83,13 @@ class RclConfig {
|
|||||||
/** Variant with autoconversion to bool */
|
/** Variant with autoconversion to bool */
|
||||||
bool getConfParam(const std::string &name, bool *value);
|
bool getConfParam(const std::string &name, bool *value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get list of config names under current sk, with possible
|
||||||
|
* wildcard filtering
|
||||||
|
*/
|
||||||
|
list<string> getConfNames(const char *pattern = 0) {
|
||||||
|
return m_conf->getNames(m_keydir, pattern);
|
||||||
|
}
|
||||||
/** Get default charset for current keydir (was set during setKeydir)
|
/** Get default charset for current keydir (was set during setKeydir)
|
||||||
* filenames are handled differently */
|
* filenames are handled differently */
|
||||||
const string &getDefCharset(bool filename = false);
|
const string &getDefCharset(bool filename = false);
|
||||||
@ -187,9 +194,6 @@ class RclConfig {
|
|||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
list<string> getConfNames(const string &sk) {
|
|
||||||
return m_conf->getNames(sk);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_ok;
|
int m_ok;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user