diff --git a/examples/async.rs b/examples/async.rs index ae0235b..9c36730 100644 --- a/examples/async.rs +++ b/examples/async.rs @@ -54,7 +54,7 @@ impl Default for ModuleConfig { } } -static mut ngx_http_async_commands: [ngx_command_t; 2] = [ +static mut NGX_HTTP_ASYNC_COMMANDS: [ngx_command_t; 2] = [ ngx_command_t { name: ngx_string!("async"), type_: (NGX_HTTP_LOC_CONF | NGX_CONF_TAKE1) as ngx_uint_t, @@ -66,7 +66,7 @@ static mut ngx_http_async_commands: [ngx_command_t; 2] = [ ngx_null_command!(), ]; -static ngx_http_async_module_ctx: ngx_http_module_t = ngx_http_module_t { +static NGX_HTTP_ASYNC_MODULE_CTX: ngx_http_module_t = ngx_http_module_t { preconfiguration: Some(Module::preconfiguration), postconfiguration: Some(Module::postconfiguration), create_main_conf: Some(Module::create_main_conf), @@ -83,6 +83,7 @@ static ngx_http_async_module_ctx: ngx_http_module_t = ngx_http_module_t { ngx::ngx_modules!(ngx_http_async_module); #[used] +#[allow(non_upper_case_globals)] #[cfg_attr(not(feature = "export-modules"), no_mangle)] pub static mut ngx_http_async_module: ngx_module_t = ngx_module_t { ctx_index: ngx_uint_t::MAX, @@ -93,8 +94,8 @@ pub static mut ngx_http_async_module: ngx_module_t = ngx_module_t { version: nginx_version as ngx_uint_t, signature: NGX_RS_MODULE_SIGNATURE.as_ptr() as *const c_char, - ctx: &ngx_http_async_module_ctx as *const _ as *mut _, - commands: unsafe { &ngx_http_async_commands[0] as *const _ as *mut _ }, + ctx: &NGX_HTTP_ASYNC_MODULE_CTX as *const _ as *mut _, + commands: unsafe { &NGX_HTTP_ASYNC_COMMANDS[0] as *const _ as *mut _ }, type_: NGX_HTTP_MODULE as ngx_uint_t, init_master: None, diff --git a/examples/awssig.rs b/examples/awssig.rs index 0418c4d..aaadf6d 100644 --- a/examples/awssig.rs +++ b/examples/awssig.rs @@ -42,7 +42,7 @@ struct ModuleConfig { s3_endpoint: String, } -static mut ngx_http_awssigv4_commands: [ngx_command_t; 6] = [ +static mut NGX_HTTP_AWSSIGV4_COMMANDS: [ngx_command_t; 6] = [ ngx_command_t { name: ngx_string!("awssigv4"), type_: (NGX_HTTP_LOC_CONF | NGX_HTTP_SRV_CONF | NGX_CONF_TAKE1) as ngx_uint_t, @@ -86,7 +86,7 @@ static mut ngx_http_awssigv4_commands: [ngx_command_t; 6] = [ ngx_null_command!(), ]; -static ngx_http_awssigv4_module_ctx: ngx_http_module_t = ngx_http_module_t { +static NGX_HTTP_AWSSIGV4_MODULE_CTX: ngx_http_module_t = ngx_http_module_t { preconfiguration: Some(Module::preconfiguration), postconfiguration: Some(Module::postconfiguration), create_main_conf: Some(Module::create_main_conf), @@ -103,6 +103,7 @@ static ngx_http_awssigv4_module_ctx: ngx_http_module_t = ngx_http_module_t { ngx::ngx_modules!(ngx_http_awssigv4_module); #[used] +#[allow(non_upper_case_globals)] #[cfg_attr(not(feature = "export-modules"), no_mangle)] pub static mut ngx_http_awssigv4_module: ngx_module_t = ngx_module_t { ctx_index: ngx_uint_t::MAX, @@ -113,8 +114,8 @@ pub static mut ngx_http_awssigv4_module: ngx_module_t = ngx_module_t { version: nginx_version as ngx_uint_t, signature: NGX_RS_MODULE_SIGNATURE.as_ptr() as *const c_char, - ctx: &ngx_http_awssigv4_module_ctx as *const _ as *mut _, - commands: unsafe { &ngx_http_awssigv4_commands[0] as *const _ as *mut _ }, + ctx: &NGX_HTTP_AWSSIGV4_MODULE_CTX as *const _ as *mut _, + commands: unsafe { &NGX_HTTP_AWSSIGV4_COMMANDS[0] as *const _ as *mut _ }, type_: NGX_HTTP_MODULE as ngx_uint_t, init_master: None, diff --git a/examples/curl.rs b/examples/curl.rs index 3a3706e..d046aa3 100644 --- a/examples/curl.rs +++ b/examples/curl.rs @@ -36,7 +36,7 @@ struct ModuleConfig { enable: bool, } -static mut ngx_http_curl_commands: [ngx_command_t; 2] = [ +static mut NGX_HTTP_CURL_COMMANDS: [ngx_command_t; 2] = [ ngx_command_t { name: ngx_string!("curl"), type_: (NGX_HTTP_LOC_CONF | NGX_CONF_TAKE1) as ngx_uint_t, @@ -48,7 +48,7 @@ static mut ngx_http_curl_commands: [ngx_command_t; 2] = [ ngx_null_command!(), ]; -static ngx_http_curl_module_ctx: ngx_http_module_t = ngx_http_module_t { +static NGX_HTTP_CURL_MODULE_CTX: ngx_http_module_t = ngx_http_module_t { preconfiguration: Some(Module::preconfiguration), postconfiguration: Some(Module::postconfiguration), create_main_conf: Some(Module::create_main_conf), @@ -65,6 +65,7 @@ static ngx_http_curl_module_ctx: ngx_http_module_t = ngx_http_module_t { ngx::ngx_modules!(ngx_http_curl_module); #[used] +#[allow(non_upper_case_globals)] #[cfg_attr(not(feature = "export-modules"), no_mangle)] pub static mut ngx_http_curl_module: ngx_module_t = ngx_module_t { ctx_index: ngx_uint_t::MAX, @@ -75,8 +76,8 @@ pub static mut ngx_http_curl_module: ngx_module_t = ngx_module_t { version: nginx_version as ngx_uint_t, signature: NGX_RS_MODULE_SIGNATURE.as_ptr() as *const c_char, - ctx: &ngx_http_curl_module_ctx as *const _ as *mut _, - commands: unsafe { &ngx_http_curl_commands[0] as *const _ as *mut _ }, + ctx: &NGX_HTTP_CURL_MODULE_CTX as *const _ as *mut _, + commands: unsafe { &NGX_HTTP_CURL_COMMANDS[0] as *const _ as *mut _ }, type_: NGX_HTTP_MODULE as ngx_uint_t, init_master: None, diff --git a/examples/httporigdst.rs b/examples/httporigdst.rs index 031a325..7ea1315 100644 --- a/examples/httporigdst.rs +++ b/examples/httporigdst.rs @@ -76,7 +76,7 @@ impl NgxHttpOrigDstCtx { } } -static ngx_http_orig_dst_module_ctx: ngx_http_module_t = ngx_http_module_t { +static NGX_HTTP_ORIG_DST_MODULE_CTX: ngx_http_module_t = ngx_http_module_t { preconfiguration: Some(Module::preconfiguration), postconfiguration: Some(Module::postconfiguration), create_main_conf: Some(Module::create_main_conf), @@ -93,6 +93,7 @@ static ngx_http_orig_dst_module_ctx: ngx_http_module_t = ngx_http_module_t { ngx::ngx_modules!(ngx_http_orig_dst_module); #[used] +#[allow(non_upper_case_globals)] #[cfg_attr(not(feature = "export-modules"), no_mangle)] pub static mut ngx_http_orig_dst_module: ngx_module_t = ngx_module_t { ctx_index: ngx_uint_t::MAX, @@ -102,7 +103,7 @@ pub static mut ngx_http_orig_dst_module: ngx_module_t = ngx_module_t { spare1: 0, version: nginx_version as ngx_uint_t, signature: NGX_RS_MODULE_SIGNATURE.as_ptr() as *const c_char, - ctx: &ngx_http_orig_dst_module_ctx as *const _ as *mut _, + ctx: &NGX_HTTP_ORIG_DST_MODULE_CTX as *const _ as *mut _, commands: std::ptr::null_mut(), type_: NGX_HTTP_MODULE as ngx_uint_t, @@ -124,7 +125,7 @@ pub static mut ngx_http_orig_dst_module: ngx_module_t = ngx_module_t { spare_hook7: 0, }; -static mut ngx_http_orig_dst_vars: [ngx_http_variable_t; 3] = [ +static mut NGX_HTTP_ORIG_DST_VARS: [ngx_http_variable_t; 3] = [ // ngx_str_t name // ngx_http_set_variable_pt set_handler // ngx_http_get_variable_pt get_handler @@ -297,7 +298,7 @@ impl HTTPModule for Module { // static ngx_int_t ngx_http_orig_dst_add_variables(ngx_conf_t *cf) unsafe extern "C" fn preconfiguration(cf: *mut ngx_conf_t) -> ngx_int_t { - for mut v in ngx_http_orig_dst_vars { + for mut v in NGX_HTTP_ORIG_DST_VARS { if v.name.len == 0 { break; } diff --git a/examples/upstream.rs b/examples/upstream.rs index 2d096bf..7056813 100644 --- a/examples/upstream.rs +++ b/examples/upstream.rs @@ -76,7 +76,7 @@ impl Default for UpstreamPeerData { } } -static ngx_http_upstream_custom_ctx: ngx_http_module_t = ngx_http_module_t { +static NGX_HTTP_UPSTREAM_CUSTOM_CTX: ngx_http_module_t = ngx_http_module_t { preconfiguration: Some(Module::preconfiguration), postconfiguration: Some(Module::postconfiguration), create_main_conf: Some(Module::create_main_conf), @@ -87,7 +87,7 @@ static ngx_http_upstream_custom_ctx: ngx_http_module_t = ngx_http_module_t { merge_loc_conf: Some(Module::merge_loc_conf), }; -static mut ngx_http_upstream_custom_commands: [ngx_command_t; 2] = [ +static mut NGX_HTTP_UPSTREAM_CUSTOM_COMMANDS: [ngx_command_t; 2] = [ ngx_command_t { name: ngx_string!("custom"), type_: (NGX_HTTP_UPS_CONF | NGX_CONF_NOARGS | NGX_CONF_TAKE1) as ngx_uint_t, @@ -105,6 +105,7 @@ static mut ngx_http_upstream_custom_commands: [ngx_command_t; 2] = [ ngx::ngx_modules!(ngx_http_upstream_custom_module); #[used] +#[allow(non_upper_case_globals)] #[cfg_attr(not(feature = "export-modules"), no_mangle)] pub static mut ngx_http_upstream_custom_module: ngx_module_t = ngx_module_t { ctx_index: ngx_uint_t::MAX, @@ -115,8 +116,8 @@ pub static mut ngx_http_upstream_custom_module: ngx_module_t = ngx_module_t { version: nginx_version as ngx_uint_t, signature: NGX_RS_MODULE_SIGNATURE.as_ptr() as *const c_char, - ctx: &ngx_http_upstream_custom_ctx as *const _ as *mut _, - commands: unsafe { &ngx_http_upstream_custom_commands[0] as *const _ as *mut _ }, + ctx: &NGX_HTTP_UPSTREAM_CUSTOM_CTX as *const _ as *mut _, + commands: unsafe { &NGX_HTTP_UPSTREAM_CUSTOM_COMMANDS[0] as *const _ as *mut _ }, type_: NGX_HTTP_MODULE as ngx_uint_t, init_master: None, diff --git a/src/lib.rs b/src/lib.rs index 08e1767..641fec8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -64,18 +64,21 @@ pub mod log; macro_rules! ngx_modules { ($( $mod:ident ),+) => { #[no_mangle] + #[allow(non_upper_case_globals)] pub static mut ngx_modules: [*const $crate::ffi::ngx_module_t; $crate::count!($( $mod, )+) + 1] = [ $( unsafe { &$mod } as *const $crate::ffi::ngx_module_t, )+ ::std::ptr::null() ]; #[no_mangle] + #[allow(non_upper_case_globals)] pub static mut ngx_module_names: [*const ::std::ffi::c_char; $crate::count!($( $mod, )+) + 1] = [ $( concat!(stringify!($mod), "\0").as_ptr() as *const ::std::ffi::c_char, )+ ::std::ptr::null() ]; #[no_mangle] + #[allow(non_upper_case_globals)] pub static mut ngx_module_order: [*const ::std::ffi::c_char; 1] = [ ::std::ptr::null() ];