Mercurial > dovecot > core-2.2
annotate src/config/settings-get.pl @ 15187:02451e967a06
Renamed network.[ch] to net.[ch].
The function prefixes already started with net_ instead of network_.
And icecap wants to use network.h for other purpose. :)
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 03 Oct 2012 18:17:26 +0300 |
parents | 98d696965c91 |
children | 78749ae0c9c2 |
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"; |
13060
99da5f4f375d
master: Fail at startup if default_login_user or default_internal_user doesn't exist.
Timo Sirainen <tss@iki.fi>
parents:
12312
diff
changeset
|
6 print '#include "ipwd.h"'."\n"; |
9177
e4cc93190ec3
Moved pop3_uidl_format checking to mail-storage-settings.
Timo Sirainen <tss@iki.fi>
parents:
9159
diff
changeset
|
7 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
|
8 print '#include "file-lock.h"'."\n"; |
11634
7f19062f58fd
Renamed fsync_disable to mail_fsync=optimized|always|never.
Timo Sirainen <tss@iki.fi>
parents:
11007
diff
changeset
|
9 print '#include "fsync-mode.h"'."\n"; |
12312
28eaaa23f2c6
lib-storage: Added support for saving mail attachments separately via filesystem API.
Timo Sirainen <tss@iki.fi>
parents:
11634
diff
changeset
|
10 print '#include "hash-format.h"'."\n"; |
15187
02451e967a06
Renamed network.[ch] to net.[ch].
Timo Sirainen <tss@iki.fi>
parents:
14159
diff
changeset
|
11 print '#include "net.h"'."\n"; |
13793
ee783a878120
Moved autocreate plugin functionality into lib-storage.
Timo Sirainen <tss@iki.fi>
parents:
13060
diff
changeset
|
12 print '#include "unichar.h"'."\n"; |
9002 | 13 print '#include "settings-parser.h"'."\n"; |
14 print '#include "all-settings.h"'."\n"; | |
15 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
|
16 print '#include <unistd.h>'."\n"; |
9002 | 17 print '#define CONFIG_BINARY'."\n"; |
10179
afe52d60989c
Moved default service settings from master.conf to source code.
Timo Sirainen <tss@iki.fi>
parents:
10177
diff
changeset
|
18 print 'extern buffer_t config_all_services_buf;'; |
9002 | 19 |
10179
afe52d60989c
Moved default service settings from master.conf to source code.
Timo Sirainen <tss@iki.fi>
parents:
10177
diff
changeset
|
20 my @services = (); |
10986
b218d4ec6996
config: Parser script now supports preserving #ifdefs around service_settings.
Timo Sirainen <tss@iki.fi>
parents:
10411
diff
changeset
|
21 my @service_ifdefs = (); |
9002 | 22 my %parsers = {}; |
23 | |
24 foreach my $file (@ARGV) { | |
25 my $f; | |
26 open($f, $file) || die "Can't open $file: $@"; | |
27 | |
28 my $state = 0; | |
29 my $file_contents = ""; | |
30 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
|
31 my $code = ""; |
c37f7113b1ee
doveconf now checks that all settings are ok by calling check functions.
Timo Sirainen <tss@iki.fi>
parents:
9002
diff
changeset
|
32 my %funcs; |
10107
dcda7c495eb6
struct setting_parser_info now specifies the module name.
Timo Sirainen <tss@iki.fi>
parents:
9793
diff
changeset
|
33 my $cur_name = ""; |
10986
b218d4ec6996
config: Parser script now supports preserving #ifdefs around service_settings.
Timo Sirainen <tss@iki.fi>
parents:
10411
diff
changeset
|
34 my $ifdef = ""; |
b218d4ec6996
config: Parser script now supports preserving #ifdefs around service_settings.
Timo Sirainen <tss@iki.fi>
parents:
10411
diff
changeset
|
35 my $state_ifdef = 0; |
9002 | 36 |
37 while (<$f>) { | |
38 my $write = 0; | |
39 if ($state == 0) { | |
40 if (/struct .*_settings {/ || | |
41 /struct setting_define.*{/ || | |
42 /struct .*_default_settings = {/) { | |
43 $state++; | |
10179
afe52d60989c
Moved default service settings from master.conf to source code.
Timo Sirainen <tss@iki.fi>
parents:
10177
diff
changeset
|
44 } elsif (/^struct service_settings (.*) = {/) { |
afe52d60989c
Moved default service settings from master.conf to source code.
Timo Sirainen <tss@iki.fi>
parents:
10177
diff
changeset
|
45 $state++; |
10986
b218d4ec6996
config: Parser script now supports preserving #ifdefs around service_settings.
Timo Sirainen <tss@iki.fi>
parents:
10411
diff
changeset
|
46 if ($ifdef eq "") { |
b218d4ec6996
config: Parser script now supports preserving #ifdefs around service_settings.
Timo Sirainen <tss@iki.fi>
parents:
10411
diff
changeset
|
47 $state_ifdef = 0; |
b218d4ec6996
config: Parser script now supports preserving #ifdefs around service_settings.
Timo Sirainen <tss@iki.fi>
parents:
10411
diff
changeset
|
48 } else { |
b218d4ec6996
config: Parser script now supports preserving #ifdefs around service_settings.
Timo Sirainen <tss@iki.fi>
parents:
10411
diff
changeset
|
49 $_ = $ifdef."\n".$_; |
b218d4ec6996
config: Parser script now supports preserving #ifdefs around service_settings.
Timo Sirainen <tss@iki.fi>
parents:
10411
diff
changeset
|
50 $state_ifdef = 1; |
b218d4ec6996
config: Parser script now supports preserving #ifdefs around service_settings.
Timo Sirainen <tss@iki.fi>
parents:
10411
diff
changeset
|
51 } |
10179
afe52d60989c
Moved default service settings from master.conf to source code.
Timo Sirainen <tss@iki.fi>
parents:
10177
diff
changeset
|
52 push @services, $1; |
10986
b218d4ec6996
config: Parser script now supports preserving #ifdefs around service_settings.
Timo Sirainen <tss@iki.fi>
parents:
10411
diff
changeset
|
53 push @service_ifdefs, $ifdef; |
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
|
54 } 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
|
55 $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
|
56 $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
|
57 } 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
|
58 $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
|
59 } 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
|
60 $state = 4; |
c37f7113b1ee
doveconf now checks that all settings are ok by calling check functions.
Timo Sirainen <tss@iki.fi>
parents:
9002
diff
changeset
|
61 $code .= $_; |
9002 | 62 } |
10986
b218d4ec6996
config: Parser script now supports preserving #ifdefs around service_settings.
Timo Sirainen <tss@iki.fi>
parents:
10411
diff
changeset
|
63 |
b218d4ec6996
config: Parser script now supports preserving #ifdefs around service_settings.
Timo Sirainen <tss@iki.fi>
parents:
10411
diff
changeset
|
64 if (/(^#ifdef .*)$/ || /^(#if .*)$/) { |
b218d4ec6996
config: Parser script now supports preserving #ifdefs around service_settings.
Timo Sirainen <tss@iki.fi>
parents:
10411
diff
changeset
|
65 $ifdef = $1; |
b218d4ec6996
config: Parser script now supports preserving #ifdefs around service_settings.
Timo Sirainen <tss@iki.fi>
parents:
10411
diff
changeset
|
66 } else { |
b218d4ec6996
config: Parser script now supports preserving #ifdefs around service_settings.
Timo Sirainen <tss@iki.fi>
parents:
10411
diff
changeset
|
67 $ifdef = ""; |
b218d4ec6996
config: Parser script now supports preserving #ifdefs around service_settings.
Timo Sirainen <tss@iki.fi>
parents:
10411
diff
changeset
|
68 } |
b218d4ec6996
config: Parser script now supports preserving #ifdefs around service_settings.
Timo Sirainen <tss@iki.fi>
parents:
10411
diff
changeset
|
69 |
9159
6324a79d3ee1
Initial commit for v2.0 master rewrite. Several features are still missing.
Timo Sirainen <tss@iki.fi>
parents:
9011
diff
changeset
|
70 if (/#define.*DEF/ || /^#undef.*DEF/ || /ARRAY_DEFINE_TYPE.*_settings/) { |
9002 | 71 $write = 1; |
72 $state = 2 if (/\\$/); | |
73 } | |
74 } elsif ($state == 2) { | |
75 $write = 1; | |
76 $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
|
77 } 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
|
78 $code .= $_; |
c37f7113b1ee
doveconf now checks that all settings are ok by calling check functions.
Timo Sirainen <tss@iki.fi>
parents:
9002
diff
changeset
|
79 $state = 0 if (/\/\* <\/settings checks> \*\//); |
9002 | 80 } |
81 | |
82 if ($state == 1 || $state == 3) { | |
83 if ($state == 1) { | |
10411
3448f1bc6966
Changed settings-get.pl to understand the MEMBER() macro removal.
Timo Sirainen <tss@iki.fi>
parents:
10336
diff
changeset
|
84 if (/\.module_name = "(.*)"/) { |
10107
dcda7c495eb6
struct setting_parser_info now specifies the module name.
Timo Sirainen <tss@iki.fi>
parents:
9793
diff
changeset
|
85 $parsers{$cur_name} = $1; |
dcda7c495eb6
struct setting_parser_info now specifies the module name.
Timo Sirainen <tss@iki.fi>
parents:
9793
diff
changeset
|
86 } |
9002 | 87 if (/DEFLIST.*".*",(.*)$/) { |
88 my $value = $1; | |
89 if ($value =~ /.*&(.*)\)/) { | |
90 $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
|
91 $externs .= "extern const struct setting_parser_info $1;\n"; |
9002 | 92 } else { |
93 $state = 3; | |
94 } | |
95 } | |
96 } elsif ($state == 3) { | |
97 if (/.*&(.*)\)/) { | |
98 $parsers{$1} = 0; | |
99 } | |
100 } | |
101 | |
10336
e18645b47984
config: Allow settings plugins to specify also new default services.
Timo Sirainen <tss@iki.fi>
parents:
10181
diff
changeset
|
102 s/^static const (struct master_settings master_default_settings)/$1/; |
e18645b47984
config: Allow settings plugins to specify also new default services.
Timo Sirainen <tss@iki.fi>
parents:
10181
diff
changeset
|
103 |
9002 | 104 $write = 1; |
105 if (/};/) { | |
106 $state = 0; | |
10986
b218d4ec6996
config: Parser script now supports preserving #ifdefs around service_settings.
Timo Sirainen <tss@iki.fi>
parents:
10411
diff
changeset
|
107 if ($state_ifdef) { |
b218d4ec6996
config: Parser script now supports preserving #ifdefs around service_settings.
Timo Sirainen <tss@iki.fi>
parents:
10411
diff
changeset
|
108 $_ .= "#endif\n"; |
b218d4ec6996
config: Parser script now supports preserving #ifdefs around service_settings.
Timo Sirainen <tss@iki.fi>
parents:
10411
diff
changeset
|
109 $state_ifdef = 0; |
b218d4ec6996
config: Parser script now supports preserving #ifdefs around service_settings.
Timo Sirainen <tss@iki.fi>
parents:
10411
diff
changeset
|
110 } |
9002 | 111 } |
112 } | |
113 | |
114 $file_contents .= $_ if ($write); | |
115 } | |
116 | |
117 print "/* $file */\n"; | |
118 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
|
119 print $code; |
9002 | 120 print $file_contents; |
121 | |
122 close $f; | |
123 } | |
124 | |
10179
afe52d60989c
Moved default service settings from master.conf to source code.
Timo Sirainen <tss@iki.fi>
parents:
10177
diff
changeset
|
125 print "static struct service_settings *config_all_services[] = {\n"; |
afe52d60989c
Moved default service settings from master.conf to source code.
Timo Sirainen <tss@iki.fi>
parents:
10177
diff
changeset
|
126 |
10986
b218d4ec6996
config: Parser script now supports preserving #ifdefs around service_settings.
Timo Sirainen <tss@iki.fi>
parents:
10411
diff
changeset
|
127 for (my $i = 0; $i < scalar(@services); $i++) { |
b218d4ec6996
config: Parser script now supports preserving #ifdefs around service_settings.
Timo Sirainen <tss@iki.fi>
parents:
10411
diff
changeset
|
128 my $ifdef = $service_ifdefs[$i]; |
b218d4ec6996
config: Parser script now supports preserving #ifdefs around service_settings.
Timo Sirainen <tss@iki.fi>
parents:
10411
diff
changeset
|
129 print "$ifdef\n" if ($ifdef ne ""); |
11007
2178c4569f38
config: Fixed all-settings building script.
Timo Sirainen <tss@iki.fi>
parents:
10986
diff
changeset
|
130 print "\t&".$services[$i].",\n"; |
10986
b218d4ec6996
config: Parser script now supports preserving #ifdefs around service_settings.
Timo Sirainen <tss@iki.fi>
parents:
10411
diff
changeset
|
131 print "#endif\n" if ($ifdef ne ""); |
10179
afe52d60989c
Moved default service settings from master.conf to source code.
Timo Sirainen <tss@iki.fi>
parents:
10177
diff
changeset
|
132 } |
afe52d60989c
Moved default service settings from master.conf to source code.
Timo Sirainen <tss@iki.fi>
parents:
10177
diff
changeset
|
133 print "};\n"; |
afe52d60989c
Moved default service settings from master.conf to source code.
Timo Sirainen <tss@iki.fi>
parents:
10177
diff
changeset
|
134 print "buffer_t config_all_services_buf = {\n"; |
afe52d60989c
Moved default service settings from master.conf to source code.
Timo Sirainen <tss@iki.fi>
parents:
10177
diff
changeset
|
135 print "\tconfig_all_services, sizeof(config_all_services), { 0, }\n"; |
afe52d60989c
Moved default service settings from master.conf to source code.
Timo Sirainen <tss@iki.fi>
parents:
10177
diff
changeset
|
136 print "};\n"; |
afe52d60989c
Moved default service settings from master.conf to source code.
Timo Sirainen <tss@iki.fi>
parents:
10177
diff
changeset
|
137 |
10181
4dc080520769
config: Added support for dynamically loaded settings.
Timo Sirainen <tss@iki.fi>
parents:
10179
diff
changeset
|
138 print "const struct setting_parser_info *all_default_roots[] = {\n"; |
9002 | 139 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
|
140 my $module = $parsers{$name}; |
dcda7c495eb6
struct setting_parser_info now specifies the module name.
Timo Sirainen <tss@iki.fi>
parents:
9793
diff
changeset
|
141 next if (!$module); |
9002 | 142 |
10107
dcda7c495eb6
struct setting_parser_info now specifies the module name.
Timo Sirainen <tss@iki.fi>
parents:
9793
diff
changeset
|
143 print "\t&".$name.", \n"; |
9002 | 144 } |
10107
dcda7c495eb6
struct setting_parser_info now specifies the module name.
Timo Sirainen <tss@iki.fi>
parents:
9793
diff
changeset
|
145 print "\tNULL\n"; |
9002 | 146 print "};\n"; |
10181
4dc080520769
config: Added support for dynamically loaded settings.
Timo Sirainen <tss@iki.fi>
parents:
10179
diff
changeset
|
147 print "const struct setting_parser_info *const *all_roots = all_default_roots;\n"; |
10336
e18645b47984
config: Allow settings plugins to specify also new default services.
Timo Sirainen <tss@iki.fi>
parents:
10181
diff
changeset
|
148 print "ARRAY_TYPE(service_settings) *default_services = &master_default_settings.services;\n"; |