Mercurial > dovecot > core-2.2
annotate src/config/settings-get.pl @ 9179:f8460b27db00 HEAD
doveconf: With -p only protocol-specific settings are returned. -n and -a return human-readable output.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 30 Apr 2009 15:02:44 -0400 |
parents | e4cc93190ec3 |
children | e374a365521d |
rev | line source |
---|---|
9002 | 1 #!/usr/bin/env perl |
2 use strict; | |
3 | |
4 print '#include "lib.h"'."\n"; | |
9011
c37f7113b1ee
doveconf now checks that all settings are ok by calling check functions.
Timo Sirainen <tss@iki.fi>
parents:
9002
diff
changeset
|
5 print '#include "array.h"'."\n"; |
9177
e4cc93190ec3
Moved pop3_uidl_format checking to mail-storage-settings.
Timo Sirainen <tss@iki.fi>
parents:
9159
diff
changeset
|
6 print '#include "var-expand.h"'."\n"; |
9002 | 7 print '#include "settings-parser.h"'."\n"; |
8 print '#include "all-settings.h"'."\n"; | |
9 print '#include <stddef.h>'."\n"; | |
9011
c37f7113b1ee
doveconf now checks that all settings are ok by calling check functions.
Timo Sirainen <tss@iki.fi>
parents:
9002
diff
changeset
|
10 print '#include <unistd.h>'."\n"; |
9002 | 11 print '#define CONFIG_BINARY'."\n"; |
12 | |
13 my %parsers = {}; | |
14 | |
15 foreach my $file (@ARGV) { | |
16 my $f; | |
17 open($f, $file) || die "Can't open $file: $@"; | |
18 | |
19 my $state = 0; | |
20 my $file_contents = ""; | |
21 my $externs = ""; | |
9011
c37f7113b1ee
doveconf now checks that all settings are ok by calling check functions.
Timo Sirainen <tss@iki.fi>
parents:
9002
diff
changeset
|
22 my $code = ""; |
c37f7113b1ee
doveconf now checks that all settings are ok by calling check functions.
Timo Sirainen <tss@iki.fi>
parents:
9002
diff
changeset
|
23 my %funcs; |
9002 | 24 |
25 while (<$f>) { | |
26 my $write = 0; | |
27 if ($state == 0) { | |
28 if (/struct .*_settings {/ || | |
29 /struct setting_define.*{/ || | |
30 /struct .*_default_settings = {/) { | |
31 $state++; | |
32 } elsif (/^(static )?struct setting_parser_info (.*) = {/) { | |
33 $state++; | |
9179
f8460b27db00
doveconf: With -p only protocol-specific settings are returned. -n and -a return human-readable output.
Timo Sirainen <tss@iki.fi>
parents:
9177
diff
changeset
|
34 my $name = $2; |
f8460b27db00
doveconf: With -p only protocol-specific settings are returned. -n and -a return human-readable output.
Timo Sirainen <tss@iki.fi>
parents:
9177
diff
changeset
|
35 $parsers{$name} = 1 if ($name !~ /\*/); |
9002 | 36 } elsif (/^extern struct setting_parser_info (.*);/) { |
37 $externs .= "extern struct setting_parser_info $1;\n"; | |
9011
c37f7113b1ee
doveconf now checks that all settings are ok by calling check functions.
Timo Sirainen <tss@iki.fi>
parents:
9002
diff
changeset
|
38 } elsif (/\/\* <settings checks> \*\//) { |
c37f7113b1ee
doveconf now checks that all settings are ok by calling check functions.
Timo Sirainen <tss@iki.fi>
parents:
9002
diff
changeset
|
39 $state = 4; |
c37f7113b1ee
doveconf now checks that all settings are ok by calling check functions.
Timo Sirainen <tss@iki.fi>
parents:
9002
diff
changeset
|
40 $code .= $_; |
9002 | 41 } |
42 | |
9159
6324a79d3ee1
Initial commit for v2.0 master rewrite. Several features are still missing.
Timo Sirainen <tss@iki.fi>
parents:
9011
diff
changeset
|
43 if (/#define.*DEF/ || /^#undef.*DEF/ || /ARRAY_DEFINE_TYPE.*_settings/) { |
9002 | 44 $write = 1; |
45 $state = 2 if (/\\$/); | |
46 } | |
47 } elsif ($state == 2) { | |
48 $write = 1; | |
49 $state = 0 if (!/\\$/); | |
9011
c37f7113b1ee
doveconf now checks that all settings are ok by calling check functions.
Timo Sirainen <tss@iki.fi>
parents:
9002
diff
changeset
|
50 } elsif ($state == 4) { |
c37f7113b1ee
doveconf now checks that all settings are ok by calling check functions.
Timo Sirainen <tss@iki.fi>
parents:
9002
diff
changeset
|
51 $code .= $_; |
c37f7113b1ee
doveconf now checks that all settings are ok by calling check functions.
Timo Sirainen <tss@iki.fi>
parents:
9002
diff
changeset
|
52 $state = 0 if (/\/\* <\/settings checks> \*\//); |
9002 | 53 } |
54 | |
55 if ($state == 1 || $state == 3) { | |
56 if ($state == 1) { | |
57 if (/DEFLIST.*".*",(.*)$/) { | |
58 my $value = $1; | |
59 if ($value =~ /.*&(.*)\)/) { | |
60 $parsers{$1} = 0; | |
61 $externs .= "extern struct setting_parser_info $1;\n"; | |
62 } else { | |
63 $state = 3; | |
64 } | |
65 } | |
66 } elsif ($state == 3) { | |
67 if (/.*&(.*)\)/) { | |
68 $parsers{$1} = 0; | |
69 } | |
70 } | |
71 | |
72 $write = 1; | |
73 if (/};/) { | |
74 $state = 0; | |
75 } | |
76 } | |
77 | |
78 $file_contents .= $_ if ($write); | |
79 } | |
80 | |
81 print "/* $file */\n"; | |
82 print $externs; | |
9011
c37f7113b1ee
doveconf now checks that all settings are ok by calling check functions.
Timo Sirainen <tss@iki.fi>
parents:
9002
diff
changeset
|
83 print $code; |
9002 | 84 print $file_contents; |
85 | |
86 close $f; | |
87 } | |
88 | |
89 print "struct config_setting_parser_list config_setting_parsers[] = {\n"; | |
90 foreach my $name (keys %parsers) { | |
91 next if (!$parsers{$name}); | |
92 | |
93 my $module = ""; | |
94 if ($name =~ /^([^_]*)/) { | |
95 $module = $1; | |
96 } | |
97 print " { \"$module\", &".$name.", NULL, NULL }, \n"; | |
98 } | |
99 print " { NULL, NULL, NULL, NULL }\n"; | |
100 print "};\n"; |