Welcome! Log In Create A New Profile

Advanced

Re: not sure how to associate a variable's get_handler with its context

June 21, 2011 06:18AM
perfect, i will do that.

thanks for the reply



On Tue, Jun 21, 2011 at 18:13, Maxim Dounin <mdounin@mdounin.ru> wrote:
> Hello!
>
> On Tue, Jun 21, 2011 at 05:25:12PM +0800, Mauro Stettler wrote:
>
>> hi
>>
>> i've implemented a simple nginx module to uppercase/lowercase a
>> variable. but i'm not sure if i did it the right way. the code can be
>> found here:
>>
>> https://github.com/replay/ngx_http_lower_upper_case/blob/master/ngx_http_lower_upper_case.c
>>
>> the thing that i'm very uncertain about is that i want to set a
>> get_handler for the destination variable like the following:
>>
>> 168     v->get_handler = ngx_http_do_lower_upper;
>>
>> the problem is that i will need to pass some data to this function
>> which is specific to this variable, and its possible that my
>> upper/lower casing directives are used multiple times in one nginx
>
> [...]
>
>> a possible alternative solution would be to use the
>> ngx_http_variable_t struct's data element and store the array index
>> there, like that:
>>
>> 164     v->data = lucf->lucases->nelts - 1;
>>
>> this would be convenient because the content of the data element is
>
> "data" is specifically designed for such type of things.
>
>> always passed as the third argument to the get_handler. but i'm not
>> sure if its ok to store an array index into an element of type
>> uintptr_t.
>
> It's ok.
>
> Per C standard uintptr_t must be able to hold any pointer, and
> hence you won't be able to store in memory any array (of bytes or
> more) which index won't fit into uintptr_t.  Moreover, nginx
> actually uses uintptr_t as it's main integer type ngx_uint_t
> (which is used for array indexes as well).
>
> Maxim Dounin
>
> _______________________________________________
> nginx-devel mailing list
> nginx-devel@nginx.org
> http://nginx.org/mailman/listinfo/nginx-devel
>

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

not sure how to associate a variable's get_handler with its context

replay 2097 June 21, 2011 05:26AM

Re: not sure how to associate a variable's get_handler with its context

Maxim Dounin 601 June 21, 2011 06:14AM

Re: not sure how to associate a variable's get_handler with its context

replay 1360 June 21, 2011 06:18AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 76
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready