68d3e914236ca536248088af9e8549ecded4c7db
[ardour.git] / cfgtool / cfgtool.cc
1 #include <stdio.h>
2 #include "pbd/xml++.h"
3 #include "ardour/rc_configuration.h"
4
5 using namespace ARDOUR;
6 using namespace std;
7
8 int main (int argc, char **argv) {
9         if (argc < 2) {
10                 fprintf(stderr, "Usage: %s [-h] <file-name>\n", argv[0]);
11                 return -1;
12         }
13
14         if (!strcmp (argv[1], "-h") || !strcmp (argv[1], "--help")) {
15                 fprintf(stdout, "Usage: %s <file-name>\n\n", argv[0]);
16                 fprintf(stdout, "Writes the default Ardour config to the given file\n");
17                 return 0;
18         }
19
20         setenv ("ARDOUR_DLL_PATH", "/xxx", 1);
21         setenv ("ARDOUR_CONFIG_PATH", "/xxx", 1);
22
23         if (!ARDOUR::init (false, true, "/xxx")) {
24                 fprintf(stderr, "Failed to initialize libardour\n");
25                 return -1;
26         }
27
28         RCConfiguration * rc = new RCConfiguration;
29         XMLNode& state = rc->get_state();
30
31         XMLNode* cfg = state.child ("Config");
32         cfg->remove_nodes_and_delete ("name", "donate-url");
33         cfg->remove_nodes_and_delete ("name", "osx_pingback-url");
34         cfg->remove_nodes_and_delete ("name", "linux-pingback-url");
35         cfg->remove_nodes_and_delete ("name", "updates-url");
36         cfg->remove_nodes_and_delete ("name", "freesound-download-dir"); // user specific
37
38         XMLTree tree;
39         tree.set_root (&state);
40
41         if (!tree.write (argv[1])) {
42                 fprintf(stderr, "Error saving config file '%s'\n", argv[1]);
43                 return -1;
44         }
45
46         return 0;
47 }