aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tools/Configger/Main.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Tools/Configger/Main.cs')
-rw-r--r--OpenSim/Tools/Configger/Main.cs108
1 files changed, 108 insertions, 0 deletions
diff --git a/OpenSim/Tools/Configger/Main.cs b/OpenSim/Tools/Configger/Main.cs
new file mode 100644
index 0000000..c85f0d2
--- /dev/null
+++ b/OpenSim/Tools/Configger/Main.cs
@@ -0,0 +1,108 @@
1using Nini.Config;
2using System;
3
4namespace Careminster
5{
6 public class Configger
7 {
8 public static int Main(string[] args)
9 {
10 ArgvConfigSource argvConfig = new ArgvConfigSource(args);
11 argvConfig.AddSwitch("Startup", "format", "f");
12
13 IConfig startupConfig = argvConfig.Configs["Startup"];
14
15 string format = startupConfig.GetString("format", "ini");
16
17 ConfigurationLoader loader = new ConfigurationLoader();
18
19 IConfigSource s = loader.LoadConfigSettings();
20
21 if (format == "mysql")
22 {
23 foreach (IConfig c in s.Configs)
24 {
25 foreach (string k in c.GetKeys())
26 {
27 string v = c.GetString(k);
28
29 if (k.StartsWith("Include-"))
30 continue;
31 Console.WriteLine("insert ignore into config (section, name, value) values ('{0}', '{1}', '{2}');", c.Name, k, v);
32 }
33 }
34 }
35 else if (format == "xml")
36 {
37 Console.WriteLine("<Nini>");
38
39 foreach (IConfig c in s.Configs)
40 {
41 int count = 0;
42
43 foreach (string k in c.GetKeys())
44 {
45 if (k.StartsWith("Include-"))
46 continue;
47
48 count++;
49 }
50
51 if (count > 0)
52 {
53 Console.WriteLine("<Section Name=\"{0}\">", c.Name);
54
55 foreach (string k in c.GetKeys())
56 {
57 string v = c.GetString(k);
58
59 if (k.StartsWith("Include-"))
60 continue;
61 Console.WriteLine(" <Key Name=\"{0}\" Value=\"{1}\" />", k, v);
62
63 Console.WriteLine("</Section>");
64 }
65 }
66 }
67 Console.WriteLine("</Nini>");
68 }
69 else if (format == "ini")
70 {
71 foreach (IConfig c in s.Configs)
72 {
73 int count = 0;
74
75 foreach (string k in c.GetKeys())
76 {
77 if (k.StartsWith("Include-"))
78 continue;
79
80 count++;
81 }
82
83 if (count > 0)
84 {
85 Console.WriteLine("[{0}]", c.Name);
86
87 foreach (string k in c.GetKeys())
88 {
89 string v = c.GetString(k);
90
91 if (k.StartsWith("Include-"))
92 continue;
93 Console.WriteLine("{0} = \"{1}\"", k, v);
94 }
95
96 Console.WriteLine();
97 }
98 }
99 }
100 else
101 {
102 Console.WriteLine("Error: unknown format: {0}", format);
103 }
104
105 return 0;
106 }
107 }
108}