diff options
author | Kitto Flora | 2010-02-12 14:08:32 -0500 |
---|---|---|
committer | Kitto Flora | 2010-02-12 14:08:32 -0500 |
commit | 6a70349512a612948918db2f2f485e87b0bc87e6 (patch) | |
tree | bdbb11f3ec840c7a14402f0acdc302b04d5a0692 /OpenSim/Tools/Configger/Main.cs | |
parent | Merge branch 'master' of ssh://3dhosting.de/var/git/careminster (diff) | |
parent | Resolve a merge issue (diff) | |
download | opensim-SC-6a70349512a612948918db2f2f485e87b0bc87e6.zip opensim-SC-6a70349512a612948918db2f2f485e87b0bc87e6.tar.gz opensim-SC-6a70349512a612948918db2f2f485e87b0bc87e6.tar.bz2 opensim-SC-6a70349512a612948918db2f2f485e87b0bc87e6.tar.xz |
Merge branch 'master' of ssh://3dhosting.de/var/git/careminster
Diffstat (limited to 'OpenSim/Tools/Configger/Main.cs')
-rw-r--r-- | OpenSim/Tools/Configger/Main.cs | 108 |
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..192cfce --- /dev/null +++ b/OpenSim/Tools/Configger/Main.cs | |||
@@ -0,0 +1,108 @@ | |||
1 | using Nini.Config; | ||
2 | using System; | ||
3 | |||
4 | namespace 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 | |||
64 | Console.WriteLine("</Section>"); | ||
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 | } | ||