You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by eeadev dev <ee...@gmail.com> on 2017/09/20 09:55:01 UTC

[users@httpd] setting getting variable to be changed in production and read in my C module

I have to write a set of variable to be read from my C module. Those
variable could be change when the code is in production, similar to what u
would write in a java properties file.

What is the proper way to do it and which functions to use?

   1. write the in the httpd.conf (what is the API for getting/setting a
   var visible in all the apache web server)
   2. write them in the [module].conf (what is the API for getting/setting
   a var visible in all my module)
   3. write them in another file, opening it with c open and parse it in
   the C way

I saw there is this API apr_env_* where are those variable meant to be?

thanks

Re: [users@httpd] setting getting variable to be changed in production and read in my C module

Posted by eeadev dev <ee...@gmail.com>.
actually noone is working "${VAR_NAME}" nor $VAR_NAME nor VAR_NAME

2017-09-20 5:07 GMT-07:00 eeadev dev <ee...@gmail.com>:

> is there anything similar but related to my module?
> for instance, now I have mymodule.conf I would prefer to write it there
> than in the general conf file, is it possible to define my var there and
> use ap_resolve_env()?
>
> 2017-09-20 4:16 GMT-07:00 Yann Ylavic <yl...@gmail.com>:
>
>> On Wed, Sep 20, 2017 at 1:11 PM, Yann Ylavic <yl...@gmail.com>
>> wrote:
>> > On Wed, Sep 20, 2017 at 12:58 PM, Yann Ylavic <yl...@gmail.com>
>> wrote:
>> >> On Wed, Sep 20, 2017 at 11:55 AM, eeadev dev <ee...@gmail.com> wrote:
>> >>> I have to write a set of variable to be read from my C module. Those
>> >>> variable could be change when the code is in production, similar to
>> what u
>> >>> would write in a java properties file.
>> >>>
>> >>> What is the proper way to do it and which functions to use?
>> >>>
>> >>> write the in the httpd.conf (what is the API for getting/setting a var
>> >>> visible in all the apache web server)
>> >>
>> >> You could:
>> >>   Define VAR_NAME "some_value"
>> >> in "httpd.conf" and then:
>> >>   const char *var_value = ap_resolve_env(some_pool, "VAR_NAME");
>> >> in your module for example.
>> >
>> > Hmm, actually you'd have to use (note the leading $):
>> >    const char *var_value = ap_resolve_env(some_pool, "$VAR_NAME");
>> > in your module.
>>
>> OK, sorry for not having looked at ap_resolve_env() more thoroughly first.
>>
>> What you'd have to use in your module is in fact:
>>     const char *var_value = ap_resolve_env(some_pool, "${VAR_NAME}");
>>
>> >
>> > So it may not be appropriate if "VAR_NAME" was instead a C variable
>> > like var_name (which you'd have to prefix...).
>>
>> This still stands, even worse (prefix + suffix).
>>
>> But maybe simple enough if you'll only use string literals...
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>> For additional commands, e-mail: users-help@httpd.apache.org
>>
>>
>

Re: [users@httpd] setting getting variable to be changed in production and read in my C module

Posted by eeadev dev <ee...@gmail.com>.
is there anything similar but related to my module?
for instance, now I have mymodule.conf I would prefer to write it there
than in the general conf file, is it possible to define my var there and
use ap_resolve_env()?

2017-09-20 4:16 GMT-07:00 Yann Ylavic <yl...@gmail.com>:

> On Wed, Sep 20, 2017 at 1:11 PM, Yann Ylavic <yl...@gmail.com> wrote:
> > On Wed, Sep 20, 2017 at 12:58 PM, Yann Ylavic <yl...@gmail.com>
> wrote:
> >> On Wed, Sep 20, 2017 at 11:55 AM, eeadev dev <ee...@gmail.com> wrote:
> >>> I have to write a set of variable to be read from my C module. Those
> >>> variable could be change when the code is in production, similar to
> what u
> >>> would write in a java properties file.
> >>>
> >>> What is the proper way to do it and which functions to use?
> >>>
> >>> write the in the httpd.conf (what is the API for getting/setting a var
> >>> visible in all the apache web server)
> >>
> >> You could:
> >>   Define VAR_NAME "some_value"
> >> in "httpd.conf" and then:
> >>   const char *var_value = ap_resolve_env(some_pool, "VAR_NAME");
> >> in your module for example.
> >
> > Hmm, actually you'd have to use (note the leading $):
> >    const char *var_value = ap_resolve_env(some_pool, "$VAR_NAME");
> > in your module.
>
> OK, sorry for not having looked at ap_resolve_env() more thoroughly first.
>
> What you'd have to use in your module is in fact:
>     const char *var_value = ap_resolve_env(some_pool, "${VAR_NAME}");
>
> >
> > So it may not be appropriate if "VAR_NAME" was instead a C variable
> > like var_name (which you'd have to prefix...).
>
> This still stands, even worse (prefix + suffix).
>
> But maybe simple enough if you'll only use string literals...
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

Re: [users@httpd] setting getting variable to be changed in production and read in my C module

Posted by Yann Ylavic <yl...@gmail.com>.
On Wed, Sep 20, 2017 at 1:11 PM, Yann Ylavic <yl...@gmail.com> wrote:
> On Wed, Sep 20, 2017 at 12:58 PM, Yann Ylavic <yl...@gmail.com> wrote:
>> On Wed, Sep 20, 2017 at 11:55 AM, eeadev dev <ee...@gmail.com> wrote:
>>> I have to write a set of variable to be read from my C module. Those
>>> variable could be change when the code is in production, similar to what u
>>> would write in a java properties file.
>>>
>>> What is the proper way to do it and which functions to use?
>>>
>>> write the in the httpd.conf (what is the API for getting/setting a var
>>> visible in all the apache web server)
>>
>> You could:
>>   Define VAR_NAME "some_value"
>> in "httpd.conf" and then:
>>   const char *var_value = ap_resolve_env(some_pool, "VAR_NAME");
>> in your module for example.
>
> Hmm, actually you'd have to use (note the leading $):
>    const char *var_value = ap_resolve_env(some_pool, "$VAR_NAME");
> in your module.

OK, sorry for not having looked at ap_resolve_env() more thoroughly first.

What you'd have to use in your module is in fact:
    const char *var_value = ap_resolve_env(some_pool, "${VAR_NAME}");

>
> So it may not be appropriate if "VAR_NAME" was instead a C variable
> like var_name (which you'd have to prefix...).

This still stands, even worse (prefix + suffix).

But maybe simple enough if you'll only use string literals...

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] setting getting variable to be changed in production and read in my C module

Posted by Yann Ylavic <yl...@gmail.com>.
On Wed, Sep 20, 2017 at 12:58 PM, Yann Ylavic <yl...@gmail.com> wrote:
> On Wed, Sep 20, 2017 at 11:55 AM, eeadev dev <ee...@gmail.com> wrote:
>> I have to write a set of variable to be read from my C module. Those
>> variable could be change when the code is in production, similar to what u
>> would write in a java properties file.
>>
>> What is the proper way to do it and which functions to use?
>>
>> write the in the httpd.conf (what is the API for getting/setting a var
>> visible in all the apache web server)
>
> You could:
>   Define VAR_NAME "some_value"
> in "httpd.conf" and then:
>   const char *var_value = ap_resolve_env(some_pool, "VAR_NAME");
> in your module for example.

Hmm, actually you'd have to use (note the leading $):
   const char *var_value = ap_resolve_env(some_pool, "$VAR_NAME");
in your module.

So it may not be appropriate if "VAR_NAME" was instead a C variable
like var_name (which you'd have to prefix...).

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] setting getting variable to be changed in production and read in my C module

Posted by Yann Ylavic <yl...@gmail.com>.
On Wed, Sep 20, 2017 at 12:58 PM, Yann Ylavic <yl...@gmail.com> wrote:
> On Wed, Sep 20, 2017 at 11:55 AM, eeadev dev <ee...@gmail.com> wrote:
>> I have to write a set of variable to be read from my C module. Those
>> variable could be change when the code is in production, similar to what u
>> would write in a java properties file.
>>
>> What is the proper way to do it and which functions to use?
>>
>> write the in the httpd.conf (what is the API for getting/setting a var
>> visible in all the apache web server)
>
> You could:
>   Define VAR_NAME "some_value"
> in "httpd.conf" and then:
>   const char *var_value = ap_resolve_env(some_pool, "VAR_NAME");
> in your module for example.

Please note that Define serves other purposes (see [1]), but for the
use case you describe it should work...

[1] https://httpd.apache.org/docs/2.4/en/mod/core.html#define

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] setting getting variable to be changed in production and read in my C module

Posted by Yann Ylavic <yl...@gmail.com>.
On Wed, Sep 20, 2017 at 11:55 AM, eeadev dev <ee...@gmail.com> wrote:
> I have to write a set of variable to be read from my C module. Those
> variable could be change when the code is in production, similar to what u
> would write in a java properties file.
>
> What is the proper way to do it and which functions to use?
>
> write the in the httpd.conf (what is the API for getting/setting a var
> visible in all the apache web server)

You could:
  Define VAR_NAME "some_value"
in "httpd.conf" and then:
  const char *var_value = ap_resolve_env(some_pool, "VAR_NAME");
in your module for example.

No need for your module to add its own directive(s) for that, but it could too.


Regards,
Yann.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org