Files
server/usr/share/passenger/ngx_http_passenger_module/ConfigGeneral/AutoGeneratedDefinitions.c.cxxcodebuilder
2026-01-07 20:52:11 +01:00

147 lines
4.3 KiB
Plaintext

# Phusion Passenger - https://www.phusionpassenger.com/
# Copyright (c) 2010-2025 Asynchronous B.V.
#
# "Passenger", "Phusion Passenger" and "Union Station" are registered
# trademarks of Asynchronous B.V.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
# This file uses the cxxcodebuilder API. Learn more at:
# https://github.com/phusion/cxxcodebuilder
require 'phusion_passenger/nginx/config_options'
def main
set_indent_string ' '
comment copyright_header_for(__FILE__), 1
separator
comment %q{
ConfigGeneral/AutoGeneratedDefinitions.c is automatically generated from
ConfigGeneral/AutoGeneratedDefinitions.c.cxxcodebuilder,
using definitions from src/ruby_supportlib/phusion_passenger/nginx/config_options.rb.
Edits to ConfigGeneral/AutoGeneratedDefinitions.c will be lost.
To update ConfigGeneral/AutoGeneratedDefinitions.c:
rake nginx
To force regeneration of ConfigGeneral/AutoGeneratedDefinitions.c:
rm -f src/nginx_module/ConfigGeneral/AutoGeneratedDefinitions.c
rake src/nginx_module/ConfigGeneral/AutoGeneratedDefinitions.c
}
separator
ctx = self
NGINX_CONFIGURATION_OPTIONS.each do |option|
option = resolve_possible_alias(option)
struct_initializer do
element "ngx_string(#{ctx.name_for(option)})"
element "#{ctx.context_for(option)} | #{ctx.take_type_for(option)}"
element ctx.setter_function_for(option)
element ctx.struct_for(option)
element ctx.struct_field_for(option)
element ctx.post_for(option)
end
add_code ','
end
end
def resolve_possible_alias(option)
if option[:alias_for]
the_alias = NGINX_CONFIGURATION_OPTIONS.find do |o|
o[:name] == option[:alias_for]
end.dup
the_alias[:aliased_for] = option[:name]
the_alias
else
option
end
end
def name_for(option)
(option[:aliased_for] || option[:name]).inspect
end
def context_for(option)
context = option.fetch(:context, [:main, :srv, :loc, :lif])
context.map{ |c| "NGX_HTTP_#{c.to_s.upcase}_CONF" }.join(" | ")
end
def take_type_for(option)
return option[:take] if option[:take]
case option[:type]
when :string, :integer, :uinteger, :string_array, :path, :msec
"NGX_CONF_TAKE1"
when :flag
"NGX_CONF_FLAG"
when :string_keyval
"NGX_CONF_TAKE2"
else
raise "Unknown type #{option[:type].inspect} for option #{option[:name]}"
end
end
def setter_function_for(option)
return option[:function] if option[:function]
field_name = option[:name].sub(/^passenger_/, '')
"passenger_conf_set_#{field_name}"
end
def struct_for(option)
option[:struct] || "NGX_HTTP_LOC_CONF_OFFSET"
end
def struct_type_for(option)
case struct_for(option)
when "NGX_HTTP_LOC_CONF_OFFSET"
"passenger_loc_conf_t"
when "NGX_HTTP_MAIN_CONF_OFFSET"
"passenger_main_conf_t"
else
raise "Unknown struct #{struct_for(option).inspect}"
end
end
def struct_field_for(option)
if option.has_key?(:field)
if field = option[:field]
field = "autogenerated.#{field}" if field !~ /\./
"offsetof(#{struct_type_for(option)}, #{field})"
else
"0"
end
else
field = option[:name].sub(/^passenger_/, '')
field = "autogenerated.#{field}" if field !~ /\./
"offsetof(#{struct_type_for(option)}, #{field})"
end
end
def post_for(option)
option[:post] || 'NULL'
end
main