Print or modify the global configuration table. */
| 742 | |
| 743 | /** Print or modify the global configuration table. */ |
| 744 | static CLIStatus rawconfig(int argc, char** argv, ostream& os) |
| 745 | { |
| 746 | // no args, just print |
| 747 | if (argc==1) { |
| 748 | gConfig.find("",os); |
| 749 | return SUCCESS; |
| 750 | } |
| 751 | |
| 752 | // one arg, pattern match and print |
| 753 | if (argc==2) { |
| 754 | gConfig.find(argv[1],os); |
| 755 | return SUCCESS; |
| 756 | } |
| 757 | |
| 758 | // >1 args: set new value |
| 759 | string val; |
| 760 | for (int i=2; i<argc; i++) { |
| 761 | val.append(argv[i]); |
| 762 | if (i!=(argc-1)) val.append(" "); |
| 763 | } |
| 764 | bool existing = gConfig.defines(argv[1]); |
| 765 | string previousVal; |
| 766 | if (existing) { |
| 767 | previousVal = gConfig.getStr(argv[1]); |
| 768 | } |
| 769 | if (!gConfig.set(argv[1],val)) { |
| 770 | os << "DB ERROR: " << argv[1] << " change failed" << endl; |
| 771 | return FAILURE; |
| 772 | } |
| 773 | if (gConfig.isStatic(argv[1])) { |
| 774 | os << argv[1] << " is static; change takes effect on restart" << endl; |
| 775 | } |
| 776 | if (!existing) { |
| 777 | os << "defined new config " << argv[1] << " as \"" << val << "\"" << endl; |
| 778 | } else { |
| 779 | os << argv[1] << " changed from \"" << previousVal << "\" to \"" << val << "\"" << endl; |
| 780 | } |
| 781 | return SUCCESS; |
| 782 | } |
| 783 | |
| 784 | static CLIStatus trxfactory(int argc, char** argv, ostream& os) |
| 785 | { |