Mercurial > dovecot > core-2.2
annotate src/config/settings-get.pl @ 10177:d589d568a19d HEAD
Changed all settings related structs to const and changed APIs to make it work.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Fri, 23 Oct 2009 20:10:17 -0400 |
parents | dcda7c495eb6 |
children | afe52d60989c |
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"; |
9434
e374a365521d
Initial commit for making mail_storage:mailbox_list to be from 1:1 to n:n.
Timo Sirainen <tss@iki.fi>
parents:
9179
diff
changeset
|
7 print '#include "file-lock.h"'."\n"; |
9002 | 8 print '#include "settings-parser.h"'."\n"; |
9 print '#include "all-settings.h"'."\n"; | |
10 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
|
11 print '#include <unistd.h>'."\n"; |
9002 | 12 print '#define CONFIG_BINARY'."\n"; |
13 | |
14 my %parsers = {}; | |
15 | |
16 foreach my $file (@ARGV) { | |
17 my $f; | |
18 open($f, $file) || die "Can't open $file: $@"; | |
19 | |
20 my $state = 0; | |
21 my $file_contents = ""; | |
22 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
|
23 my $code = ""; |
c37f7113b1ee
doveconf now checks that all settings are ok by calling check functions.
Timo Sirainen <tss@iki.fi>
parents:
9002
diff
changeset
|
24 my %funcs; |
10107
dcda7c495eb6
struct setting_parser_info now specifies the module name.
Timo Sirainen <tss@iki.fi>
parents:
9793
diff
changeset
|
25 my $cur_name = ""; |
9002 | 26 |
27 while (<$f>) { | |
28 my $write = 0; | |
29 if ($state == 0) { | |
30 if (/struct .*_settings {/ || | |
31 /struct setting_define.*{/ || | |
32 /struct .*_default_settings = {/) { | |
33 $state++; | |
10177
d589d568a19d
Changed all settings related structs to const and changed APIs to make it work.
Timo Sirainen <tss@iki.fi>
parents:
10107
diff
changeset
|
34 } elsif (/^(static )?const struct setting_parser_info (.*) = {/) { |
10107
dcda7c495eb6
struct setting_parser_info now specifies the module name.
Timo Sirainen <tss@iki.fi>
parents:
9793
diff
changeset
|
35 $cur_name = $2; |
10177
d589d568a19d
Changed all settings related structs to const and changed APIs to make it work.
Timo Sirainen <tss@iki.fi>
parents:
10107
diff
changeset
|
36 $state++ if ($cur_name !~ /^\*default_/); |
d589d568a19d
Changed all settings related structs to const and changed APIs to make it work.
Timo Sirainen <tss@iki.fi>
parents:
10107
diff
changeset
|
37 } elsif (/^extern const struct setting_parser_info (.*);/) { |
d589d568a19d
Changed all settings related structs to const and changed APIs to make it work.
Timo Sirainen <tss@iki.fi>
parents:
10107
diff
changeset
|
38 $externs .= "extern const 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
|
39 } 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
|
40 $state = 4; |
c37f7113b1ee
doveconf now checks that all settings are ok by calling check functions.
Timo Sirainen <tss@iki.fi>
parents:
9002
diff
changeset
|
41 $code .= $_; |
9002 | 42 } |
43 | |
9159
6324a79d3ee1
Initial commit for v2.0 master rewrite. Several features are still missing.
Timo Sirainen <tss@iki.fi>
parents:
9011
diff
changeset
|
44 if (/#define.*DEF/ || /^#undef.*DEF/ || /ARRAY_DEFINE_TYPE.*_settings/) { |
9002 | 45 $write = 1; |
46 $state = 2 if (/\\$/); | |
47 } | |
48 } elsif ($state == 2) { | |
49 $write = 1; | |
50 $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
|
51 } 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
|
52 $code .= $_; |
c37f7113b1ee
doveconf now checks that all settings are ok by calling check functions.
Timo Sirainen <tss@iki.fi>
parents:
9002
diff
changeset
|
53 $state = 0 if (/\/\* <\/settings checks> \*\//); |
9002 | 54 } |
55 | |
56 if ($state == 1 || $state == 3) { | |
57 if ($state == 1) { | |
10107
dcda7c495eb6
struct setting_parser_info now specifies the module name.
Timo Sirainen <tss@iki.fi>
parents:
9793
diff
changeset
|
58 if (/MEMBER\(module_name\) "(.*)"/) { |
dcda7c495eb6
struct setting_parser_info now specifies the module name.
Timo Sirainen <tss@iki.fi>
parents:
9793
diff
changeset
|
59 $parsers{$cur_name} = $1; |
dcda7c495eb6
struct setting_parser_info now specifies the module name.
Timo Sirainen <tss@iki.fi>
parents:
9793
diff
changeset
|
60 } |
9002 | 61 if (/DEFLIST.*".*",(.*)$/) { |
62 my $value = $1; | |
63 if ($value =~ /.*&(.*)\)/) { | |
64 $parsers{$1} = 0; | |
10177
d589d568a19d
Changed all settings related structs to const and changed APIs to make it work.
Timo Sirainen <tss@iki.fi>
parents:
10107
diff
changeset
|
65 $externs .= "extern const struct setting_parser_info $1;\n"; |
9002 | 66 } else { |
67 $state = 3; | |
68 } | |
69 } | |
70 } elsif ($state == 3) { | |
71 if (/.*&(.*)\)/) { | |
72 $parsers{$1} = 0; | |
73 } | |
74 } | |
75 | |
76 $write = 1; | |
77 if (/};/) { | |
78 $state = 0; | |
79 } | |
80 } | |
81 | |
82 $file_contents .= $_ if ($write); | |
83 } | |
84 | |
85 print "/* $file */\n"; | |
86 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
|
87 print $code; |
9002 | 88 print $file_contents; |
89 | |
90 close $f; | |
91 } | |
92 | |
10107
dcda7c495eb6
struct setting_parser_info now specifies the module name.
Timo Sirainen <tss@iki.fi>
parents:
9793
diff
changeset
|
93 print "const struct setting_parser_info *all_roots[] = {\n"; |
9002 | 94 foreach my $name (keys %parsers) { |
10107
dcda7c495eb6
struct setting_parser_info now specifies the module name.
Timo Sirainen <tss@iki.fi>
parents:
9793
diff
changeset
|
95 my $module = $parsers{$name}; |
dcda7c495eb6
struct setting_parser_info now specifies the module name.
Timo Sirainen <tss@iki.fi>
parents:
9793
diff
changeset
|
96 next if (!$module); |
9002 | 97 |
10107
dcda7c495eb6
struct setting_parser_info now specifies the module name.
Timo Sirainen <tss@iki.fi>
parents:
9793
diff
changeset
|
98 print "\t&".$name.", \n"; |
9002 | 99 } |
10107
dcda7c495eb6
struct setting_parser_info now specifies the module name.
Timo Sirainen <tss@iki.fi>
parents:
9793
diff
changeset
|
100 print "\tNULL\n"; |
9002 | 101 print "};\n"; |