JezK
Edit File: page-ConfigurationSetters_cpp_cxxcodebuilder.ri
U:RDoc::TopLevel[ i I"?src/apache2_module/ConfigurationSetters.cpp.cxxcodebuilder:ETcRDoc::Parser::Simpleo:RDoc::Markup::Document:@parts[ o:RDoc::Markup::Paragraph;[I"># Phusion Passenger - https://www.phusionpassenger.com/ ;TI"5# Copyright (c) 2010-2016 Phusion Holding B.V. ;TI"# ;TI"L# "Passenger", "Phusion Passenger" and "Union Station" are registered ;TI"+# trademarks of Phusion Holding B.V. ;TI"# ;TI"U# Permission is hereby granted, free of charge, to any person obtaining a copy ;TI"V# of this software and associated documentation files (the "Software"), to deal ;TI"U# in the Software without restriction, including without limitation the rights ;TI"R# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ;TI"N# copies of the Software, and to permit persons to whom the Software is ;TI"A# furnished to do so, subject to the following conditions: ;TI"# ;TI"S# The above copyright notice and this permission notice shall be included in ;TI"<# all copies or substantial portions of the Software. ;TI"# ;TI"S# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ;TI"Q# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ;TI"T# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ;TI"O# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ;TI"V# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;TI"R# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ;TI"# THE SOFTWARE.;To:RDoc::Markup::BlankLine o; ;[I"=# This file uses the cxxcodebuilder API. Learn more at: ;TI"0# https://github.com/phusion/cxxcodebuilder;T@$o; ;[I"7require 'phusion_passenger/apache2/config_options';T@$o; ;[I" def main;To:RDoc::Markup::Verbatim;[VI"/comment copyright_header_for(__FILE__), 1 ;TI" ;TI"separator ;TI" ;TI"comment %q{ ;TI"i ConfigurationSetters.cpp is automatically generated from ConfigurationSetters.cpp.cxxcodebuilder, ;TI"_ using definitions from src/ruby_supportlib/phusion_passenger/apache2/config_options.rb. ;TI"7 Edits to ConfigurationSetters.cpp will be lost. ;TI" ;TI"+ To update ConfigurationSetters.cpp: ;TI" rake apache2 ;TI" ;TI": To force regeneration of ConfigurationSetters.cpp: ;TI"; rm -f src/apache2_module/ConfigurationSetters.cpp ;TI": rake src/apache2_module/ConfigurationSetters.cpp ;TI"} ;TI" ;TI"separator ;TI" ;TI"Wfilter_eligible_options(APACHE2_DIRECTORY_CONFIGURATION_OPTIONS).each do |option| ;TI"- func_name = function_name_for(option) ;TI" ;TI"# if option[:type] == :string ;TI"f function("static const char *#{func_name}(cmd_parms *cmd, void *pcfg, const char *arg)", %Q{ ;TI"3 DirConfig *config = (DirConfig *) pcfg; ;TI"6 config->#{struct_field_for(option)} = arg; ;TI" return NULL; ;TI" }) ;TI"' elsif option[:type] == :integer ;TI"d function "static const char *#{func_name}(cmd_parms *cmd, void *pcfg, const char *arg)" do ;TI" add_code %q[ ;TI"5 DirConfig *config = (DirConfig *) pcfg; ;TI" char *end; ;TI" long result; ;TI" ;TI"- result = strtol(arg, &end, 10); ;TI"! if (*end != '\0') { ;TI"A string message = "Invalid number specified for "; ;TI": message.append(cmd->directive->directive); ;TI"$ message.append("."); ;TI" ;TI"F char *messageStr = (char *) apr_palloc(cmd->temp_pool, ;TI"& message.size() + 1); ;TI"H memcpy(messageStr, message.c_str(), message.size() + 1); ;TI"" return messageStr; ;TI" ] ;TI" ;TI"! if option[:min_value] ;TI" add_code %Q[ ;TI"< } else if (result < #{option[:min_value]}) { ;TI"0 string message = "Value for "; ;TI"< message.append(cmd->directive->directive); ;TI"] message.append(" must be greater than or equal to #{option[:min_value]}."); ;TI" ;TI"H char *messageStr = (char *) apr_palloc(cmd->temp_pool, ;TI"( message.size() + 1); ;TI"J memcpy(messageStr, message.c_str(), message.size() + 1); ;TI"$ return messageStr; ;TI" ] ;TI" end ;TI" ;TI" add_code %Q[ ;TI" } else { ;TI"C config->#{struct_field_for(option)} = (int) result; ;TI" return NULL; ;TI" } ;TI" ] ;TI" end ;TI"$ elsif option[:type] == :flag ;TI"f function("static const char *#{func_name}(cmd_parms *cmd, void *pcfg, const char *arg)", %Q{ ;TI"3 DirConfig *config = (DirConfig *) pcfg; ;TI"1 config->#{struct_field_for(option)} = ;TI" arg ? ;TI"" DirConfig::ENABLED : ;TI"" DirConfig::DISABLED; ;TI" return NULL; ;TI" }) ;TI" else ;TI"Z raise "Unknown option type #{option[:type].inspect} for option #{option[:name]}" ;TI" end ;TI" end ;T:@format0o; ;[I"end;T@$o; ;[I")def filter_eligible_options(options);To;;[I" options.reject do |option| ;TI" option[:alias_for] || ;TI", option.fetch(:field, true).nil? || ;TI"( option[:field].to_s =~ /\./ || ;TI" option[:function] ;TI" end ;T;0o; ;[I"end;T@$o; ;[I"!def struct_field_for(option);To;;[I" if option.has_key?(:field) ;TI" option[:field] ;TI" else ;TI"4 result = option[:name].sub(/^Passenger/, '') ;TI") result[0] = result[0..0].downcase ;TI" result ;TI" end ;T;0o; ;[I"end;T@$o; ;[I"def min_value_for(option);To;;[I"option[:min_value] || 0 ;T;0o; ;[I"end;T@$o; ;[I""def function_name_for(option);To;;[ I"=function_name = option[:name].gsub(/[A-Z]/) do |letter| ;TI"# "_" + letter[0..0].downcase ;TI" end ;TI""cmd#{function_name}" ;T;0o; ;[I"end;T@$o; ;[I" main;T: @file@:0@omit_headings_from_table_of_contents_below0