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

Mauro Stettler mauro.stettler at gmail.com
Tue Jun 21 14:17:08 MSD 2011


perfect, i will do that.

thanks for the reply



On Tue, Jun 21, 2011 at 18:13, Maxim Dounin <mdounin at 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 at nginx.org
> http://nginx.org/mailman/listinfo/nginx-devel
>



More information about the nginx-devel mailing list