관리-도구
편집 파일: AutoGeneratedSetterFuncs.cpp.cxxcodebuilder
# Phusion Passenger - https://www.phusionpassenger.com/ # Copyright (c) 2010-2018 Phusion Holding B.V. # # "Passenger", "Phusion Passenger" and "Union Station" are registered # trademarks of Phusion Holding 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/apache2/config_options' def main comment copyright_header_for(__FILE__), 1 add_code %Q[ #ifndef _PASSENGER_APACHE2_MODULE_CONFIG_AUTOGENERATED_SETTER_FUNCS_CPP_ #define _PASSENGER_APACHE2_MODULE_CONFIG_AUTOGENERATED_SETTER_FUNCS_CPP_ #ifdef INTELLISENSE // These includes do nothing, but keep IntelliSense happy. #include <ap_config.h> #include <http_config.h> #include <http_log.h> #include "../Config.h" #ifdef APLOG_USE_MODULE extern "C" module AP_MODULE_DECLARE_DATA passenger_module; APLOG_USE_MODULE(passenger); #endif #endif namespace Passenger { namespace Apache2Module { ] separator comment %q{ ConfigGeneral/AutoGeneratedSetterFuncs.cpp is automatically generated from ConfigGeneral/AutoGeneratedSetterFuncs.cpp.cxxcodebuilder, using definitions from src/ruby_supportlib/phusion_passenger/apache2/config_options.rb. Edits to ConfigGeneral/AutoGeneratedSetterFuncs.cpp will be lost. To update ConfigGeneral/AutoGeneratedSetterFuncs.cpp: rake apache2 To force regeneration of ConfigGeneral/AutoGeneratedSetterFuncs.cpp: rm -f src/apache2_module/ConfigGeneral/AutoGeneratedSetterFuncs.cpp rake src/apache2_module/ConfigGeneral/AutoGeneratedSetterFuncs.cpp } separator filter_eligible_options(APACHE2_CONFIGURATION_OPTIONS).each do |option| function(setter_function_declaration_for(option)) do setter_function_body_for(option) end end separator add_code %Q[ } // namespace Apache2Module } // namespace Passenger #endif /* _PASSENGER_APACHE2_MODULE_CONFIG_AUTOGENERATED_SETTER_FUNCS_CPP_ */ ] end def filter_eligible_options(options) options.reject do |option| option[:alias_for] || option.fetch(:field, true).nil? || option[:field].to_s =~ /\./ || option[:function] end end def struct_field_for(option) if option.has_key?(:field) option[:field] else result = option[:name].sub(/^Passenger/, '') if option[:context] != :global "m#{result}" else result[0] = result[0..0].downcase result end end end def min_value_for(option) option[:min_value] || 0 end def function_name_for(option) function_name = option[:name].gsub(/[A-Z]/) do |letter| "_" + letter[0..0].downcase end "cmd#{function_name}" end def setter_function_declaration_for(option) func_name = function_name_for(option) "static const char *#{func_name}(cmd_parms *cmd, void *pcfg, const char *arg)" end def setter_function_body_for(option) if option[:obsolete] obsoletion_message = option[:obsoletion_message] || "The '#{option[:name]}' option is obsolete. Please remove this option from your configuration file." obsoletion_message = "WARNING: #{obsoletion_message}\n" add_code %Q{ fprintf(stderr, #{obsoletion_message.inspect}); fflush(stderr); return NULL; } return end case option[:context] when :global # We only warn here instead of returning an error because this issue # is not fatal: we still handle this case correctly. add_code %Q{ const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); if (err != NULL) { ap_log_perror(APLOG_MARK, APLOG_STARTUP, 0, cmd->temp_pool, "WARNING: %s", err); } } separator when :application add_code %Q{ const char *err = ap_check_cmd_context(cmd, NOT_IN_FILES); if (err != NULL) { return err; } } separator end field_reference = struct_field_for(option) if option[:context] != :global add_code %Q{ DirConfig *config = (DirConfig *) pcfg; } field_reference = "config->#{field_reference}" else field_reference = "serverConfig.#{field_reference}" end add_code %Q{ #{field_reference}SourceFile = cmd->directive->filename; #{field_reference}SourceLine = cmd->directive->line_num; #{field_reference}ExplicitlySet = true; } if option[:type] == :string add_code %Q{ #{field_reference} = arg; return NULL; } elsif option[:type] == :integer if option[:min_value] add_code %Q{ return setIntConfig(cmd, arg, #{field_reference}, #{option[:min_value]}); } else add_code %Q{ return setIntConfig(cmd, arg, #{field_reference}); } end elsif option[:type] == :flag if option[:context] == :global add_code %Q{ #{field_reference} = arg != NULL; return NULL; } else add_code %Q{ #{field_reference} = (arg != NULL) ? ENABLED : DISABLED; return NULL; } end elsif option[:type] == :string_set add_code %Q{ #{field_reference}.insert(arg); return NULL; } else raise "Unknown option type #{option[:type].inspect} for option #{option[:name]}" end end main