Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8853529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:40:37+00:00 2026-06-14T13:40:37+00:00

Is there any mechanism in the Apache httpd framework that would allow me to

  • 0

Is there any mechanism in the Apache httpd framework that would allow me to pass custom parameters from the Apache configuration file to a custom Apache module (written using the C API)? I really only need key/value pairs.

Something like in conf file:

ConfigParameter foo bar

And then in the code:

string foo = GetApacheConfigParameter("foo"); // = "bar"
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T13:40:38+00:00Added an answer on June 14, 2026 at 1:40 pm

    No; not directly. A dirty hack would be

    SetEnv foo bar
    

    in the config file – and a

    char * bar = getenv("foo"); 
    

    in your module. Anything beyond that requires the use of a proper structure on a per directory, server, etc. Normally that structure would contain a lot of specific things. In your case it would just be a single table.

    So somewhat clean way would be to simply use a table – and leave it at that:

     static const command_rec xxx_cmds[] = {
        AP_INIT_TAKE2("ConfigParameter", add_configparam, NULL, RSRC_CONF,
                  "Arbitrary key value pair"),
       {NULL}
    };
    
     static void * create_dir_config(apr_pool_t *p, char *dirspec ) {
        return ap_table_palloc(p);
     }
    
     static const char *add_configparam(cmd_parms *cmd, void *mconfig,   
                                   char *key, char *val) 
     {
        ap_table_t *pairs = (ap_table_rec *) mconfig;
        ap_table_set(pairs, key, val);
        return NULL;
     }
    
     AP_DECLARE_MODULE(xxxx_module) =
     {
       STANDARD20_MODULE_STUFF,
       xxx_create_dir_config,    /* per-directory config creator */
       ...
       xxx_cmds,                 /* command table */
    

    and then, everywhere where you want to use this do:

    apr_table_t * pairs =  (apr_table_p *) ap_get_module_config(r->request_config, &xxxx_module);
    

    or

     apr_table_t * pairs =  ap_get_module_config(s->module_config, &xxxx_module);
    

    depending on where it us used – and then use:

    char * bar = apr_table_get(pairs,"foo");
    

    or similar. See mod_example_hooks and the various our_* calls to get a pointer. Above example leaves out configs on server level and merging of configs. Add those if you need them – there is a corresponding merge call for tables. mod_alias.c et.al. have good examples.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any mechanism that I can push data into a webbrowser control from
Is there any mechanism in C# that allows one to define and declare an
I'd like to know if there are any mechanism in Akka that can have
Coming from a Django background, I'm accustomed to the framework providing a configuration mechanism
When using route names, for example with Url.RouteUrl , is there any mechanism that
Is there any mechanism in Java to reduce the memory usage while reading large
I am working with Objective-C in Xcode. I was wondering is there any mechanism
Is there any way I can set a formatter on models that will convert
Is there any mechanism in Hudson/Jenkns which automatically invokes the slave machine which ever
Is there any mechanism where I can get update notification when users try to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.