|
a/src/common/rclconfig.cpp |
|
b/src/common/rclconfig.cpp |
1 |
#ifndef lint
|
1 |
#ifndef lint
|
2 |
static char rcsid[] = "@(#$Id: rclconfig.cpp,v 1.32 2006-10-24 09:09:36 dockes Exp $ (C) 2004 J.F.Dockes";
|
2 |
static char rcsid[] = "@(#$Id: rclconfig.cpp,v 1.33 2006-11-20 15:28:14 dockes Exp $ (C) 2004 J.F.Dockes";
|
3 |
#endif
|
3 |
#endif
|
4 |
/*
|
4 |
/*
|
5 |
* This program is free software; you can redistribute it and/or modify
|
5 |
* This program is free software; you can redistribute it and/or modify
|
6 |
* it under the terms of the GNU General Public License as published by
|
6 |
* it under the terms of the GNU General Public License as published by
|
7 |
* the Free Software Foundation; either version 2 of the License, or
|
7 |
* the Free Software Foundation; either version 2 of the License, or
|
|
... |
|
... |
198 |
} else {
|
198 |
} else {
|
199 |
// Note: it seems that all versions of iconv will take
|
199 |
// Note: it seems that all versions of iconv will take
|
200 |
// iso-8859. Some won't take iso8859
|
200 |
// iso-8859. Some won't take iso8859
|
201 |
localecharset = string("ISO-8859-1");
|
201 |
localecharset = string("ISO-8859-1");
|
202 |
}
|
202 |
}
|
|
|
203 |
LOGDEB(("RclConfig::getDefCharset: localecharset [%s]\n",
|
|
|
204 |
localecharset.c_str()));
|
203 |
}
|
205 |
}
|
204 |
|
206 |
|
205 |
if (defcharset.empty()) {
|
207 |
if (defcharset.empty()) {
|
206 |
defcharset = localecharset;
|
208 |
defcharset = localecharset;
|
207 |
}
|
209 |
}
|
|
... |
|
... |
479 |
|
481 |
|
480 |
#include "debuglog.h"
|
482 |
#include "debuglog.h"
|
481 |
#include "rclinit.h"
|
483 |
#include "rclinit.h"
|
482 |
#include "rclconfig.h"
|
484 |
#include "rclconfig.h"
|
483 |
|
485 |
|
|
|
486 |
static char *thisprog;
|
|
|
487 |
|
|
|
488 |
static char usage [] =
|
|
|
489 |
" \n\n"
|
|
|
490 |
;
|
|
|
491 |
static void
|
|
|
492 |
Usage(void)
|
|
|
493 |
{
|
|
|
494 |
fprintf(stderr, "%s: usage:\n%s [-s subkey] [-q param]", thisprog, usage);
|
|
|
495 |
exit(1);
|
|
|
496 |
}
|
|
|
497 |
|
|
|
498 |
static int op_flags;
|
|
|
499 |
#define OPT_MOINS 0x1
|
|
|
500 |
#define OPT_s 0x2
|
|
|
501 |
#define OPT_q 0x4
|
|
|
502 |
|
484 |
int main(int, const char **)
|
503 |
int main(int argc, char **argv)
|
485 |
{
|
504 |
{
|
|
|
505 |
string pname, skey;
|
|
|
506 |
|
|
|
507 |
thisprog = argv[0];
|
|
|
508 |
argc--; argv++;
|
|
|
509 |
|
|
|
510 |
while (argc > 0 && **argv == '-') {
|
|
|
511 |
(*argv)++;
|
|
|
512 |
if (!(**argv))
|
|
|
513 |
/* Cas du "adb - core" */
|
|
|
514 |
Usage();
|
|
|
515 |
while (**argv)
|
|
|
516 |
switch (*(*argv)++) {
|
|
|
517 |
case 's': op_flags |= OPT_s; if (argc < 2) Usage();
|
|
|
518 |
skey = *(++argv);
|
|
|
519 |
argc--;
|
|
|
520 |
goto b1;
|
|
|
521 |
case 'q': op_flags |= OPT_q; if (argc < 2) Usage();
|
|
|
522 |
pname = *(++argv);
|
|
|
523 |
argc--;
|
|
|
524 |
goto b1;
|
|
|
525 |
default: Usage(); break;
|
|
|
526 |
}
|
|
|
527 |
b1: argc--; argv++;
|
|
|
528 |
}
|
|
|
529 |
|
|
|
530 |
if (argc != 0)
|
|
|
531 |
Usage();
|
|
|
532 |
|
486 |
string reason;
|
533 |
string reason;
|
487 |
RclConfig *config = recollinit(0, 0, reason);
|
534 |
RclConfig *config = recollinit(0, 0, reason);
|
488 |
if (config == 0 || !config->ok()) {
|
535 |
if (config == 0 || !config->ok()) {
|
489 |
cerr << "Configuration problem: " << reason << endl;
|
536 |
cerr << "Configuration problem: " << reason << endl;
|
490 |
exit(1);
|
537 |
exit(1);
|
491 |
}
|
538 |
}
|
492 |
list<string> names = config->getConfNames("");
|
539 |
if (op_flags & OPT_s)
|
493 |
names.sort();
|
540 |
config->setKeyDir(skey);
|
494 |
names.unique();
|
541 |
if (op_flags & OPT_q) {
|
495 |
for (list<string>::iterator it = names.begin(); it != names.end();it++) {
|
|
|
496 |
string value;
|
542 |
string value;
|
|
|
543 |
if (!config->getConfParam(pname, value)) {
|
|
|
544 |
fprintf(stderr, "getConfParam failed for [%s]\n", pname.c_str());
|
|
|
545 |
exit(1);
|
|
|
546 |
}
|
|
|
547 |
printf("[%s] -> [%s]\n", pname.c_str(), value.c_str());
|
|
|
548 |
} else {
|
|
|
549 |
list<string> names = config->getConfNames("");
|
|
|
550 |
names.sort();
|
|
|
551 |
names.unique();
|
|
|
552 |
for (list<string>::iterator it = names.begin();
|
|
|
553 |
it != names.end();it++) {
|
|
|
554 |
string value;
|
497 |
config->getConfParam(*it, value);
|
555 |
config->getConfParam(*it, value);
|
498 |
cout << *it << " -> [" << value << "]" << endl;
|
556 |
cout << *it << " -> [" << value << "]" << endl;
|
|
|
557 |
}
|
499 |
}
|
558 |
}
|
|
|
559 |
exit(0);
|
500 |
}
|
560 |
}
|
501 |
|
561 |
|
502 |
#endif // TEST_RCLCONFIG
|
562 |
#endif // TEST_RCLCONFIG
|