Return-Path: X-Original-To: apmail-httpd-modules-dev-archive@minotaur.apache.org Delivered-To: apmail-httpd-modules-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 484A8F332 for ; Sat, 11 May 2013 14:01:11 +0000 (UTC) Received: (qmail 89051 invoked by uid 500); 11 May 2013 14:01:11 -0000 Delivered-To: apmail-httpd-modules-dev-archive@httpd.apache.org Received: (qmail 88944 invoked by uid 500); 11 May 2013 14:01:10 -0000 Mailing-List: contact modules-dev-help@httpd.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: modules-dev@httpd.apache.org Delivered-To: mailing list modules-dev@httpd.apache.org Received: (qmail 88925 invoked by uid 99); 11 May 2013 14:01:09 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 11 May 2013 14:01:09 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of sindhi.for@gmail.com designates 209.85.223.172 as permitted sender) Received: from [209.85.223.172] (HELO mail-ie0-f172.google.com) (209.85.223.172) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 11 May 2013 14:01:03 +0000 Received: by mail-ie0-f172.google.com with SMTP id 16so9891641iea.31 for ; Sat, 11 May 2013 07:00:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=8XM5w9+Sqk0RwGaA5YC7+4MD7YAp/r90K7j3EUD4B/M=; b=aiG0x4B4rC1QIwhSyQM0h0nZSNEtwP20mKMaihsn4a8+GXl1vpFH1KBl5Qa/kwwm8w OtvgxfMtwsnSj43BHL4znvRACGfvQMFhAOlEDrSd05JA/1e13zA6YVc2hcMtX9ncdJQ/ 1IfqOo+U+fHTkQhPMErMlWAE0CUYGJ7ESRSGfT8j8w4nv2CdLplcvgHV7zCZnigVcW4R ilLRVIhUvrlkmGk9OLeYojHI30QkRbxIBML5IfFbow3Wrkrdhhs9tw11mz21DAO1BIQN mLhAAXSXk79DjTUhMRNIC85lZp2yEMHxjp1Zq8ddIpJdkXQrld3MUXpN8FGo6r7P2su9 XxJw== MIME-Version: 1.0 X-Received: by 10.50.114.106 with SMTP id jf10mr5012450igb.111.1368280842719; Sat, 11 May 2013 07:00:42 -0700 (PDT) Received: by 10.64.22.193 with HTTP; Sat, 11 May 2013 07:00:42 -0700 (PDT) In-Reply-To: <518DF619.1020405@gmail.com> References: <518A8CBB.1000003@gmail.com> <518DF619.1020405@gmail.com> Date: Sat, 11 May 2013 19:30:42 +0530 Message-ID: Subject: Re: Setting and accessing module specific directory From: Sindhi Sindhi To: modules-dev@httpd.apache.org Content-Type: multipart/alternative; boundary=047d7b3a9baa95557804dc71b55b X-Virus-Checked: Checked by ClamAV on apache.org --047d7b3a9baa95557804dc71b55b Content-Type: text/plain; charset=ISO-8859-1 Thankyou Sorin! for the detailed explanation. But I couldnt find the 64-bit version of the Windows server at http://httpd.apache.org/download.cgi I'm sorry if I'm asking a very basic question, but the above link has Unix source and Netware binaries only :( On Sat, May 11, 2013 at 1:11 PM, Sorin Manolache wrote: > On 2013-05-11 08:22, Sindhi Sindhi wrote: > >> Thankyou. >> Had one more question. What is the right way of handling this - in which >> location in Apache server directory should I be keeping my filter specific >> files? >> >> As of now the XML and other files that are read by my filter are placed in >> a new folder say "MyFilter" inside "httpd-2.4.4-win64\Apache24\**htdocs". >> Is >> this the right way of doing it? >> > > I think a more "elegant" solution would be to have the location > configurable. > > For that, you define a module-specific configuration directive. (I am not > familiar with apache 2.4, all my advice is based on apache 2.2, but I > suppose there is a sufficient degree of backwards compatibility.) > > For defining configuration directives, you have to take the following > steps: > > 1. You define one or two callback functions, create_dir_config and/or > create_server_config. You put their addresses in the corresponing places in > your module structure. These callback functions are called when apache > starts up and they should create and return an application-specific > configuration object that is opaque for apache; it sees it as a void > pointer. > > The server-wide configuration object (created by create_server_config) > contains configuration data that apply to the whole virtual host. > > The directory-wide configuration object (created by create_dir_config) > contains configuration data that apply to a or . > > So, if you have a server with 3 virtual hosts, you have 3 server > configuration objects per module. However you may have many more directory > configuration objects, depending on your Locations and Directories. > > 2. You add one entry to the cmds array of your module structure for each > configuration directive that you want to define. Each cmds array entry has > a placeholder for your configuration directive-specific callback. The > callback function is invoked by apache when it parses the configuration and > it encounters the configuration directive specified by your module. > > 3. You define the configuration directive callback. The callback gets the > arguments of the configuration directive. What the callback should do is to > retrieve somehow the configuration object created by the callback in step 1 > and initialise it with the arguments passed by apache (the configuration > values). > > The directory-wide configuration object is passed in the second argument > of the configuration callback. You just have to cast the void pointer to a > pointer to the type of your configuration object. > > The server-wide configuration object is retrieved as follows: > > ap_get_module_config(params->**server->module_config, &my_module) > > where params is the cmd_parms argument of the configuration directive > callback and my_module is the name of your module structure object. > > Note that you don't need to use both a server-wide and a directory-wide > configuration object. The simplest is to use a server-wide. However, a > directory-wide gives you more configuration flexibility. > > The callbacks in steps 1-3 are not called as part of request processing. > It's more an apache startup and configuration thing. Once apache starts > processing the requests, it is properly configured and the values of your > configuration directives are stored in the configuration objects. During > request processing you'll just have to retrieve these values from the > configuration objects. This is done is step 4: > > 4. You retrieve the configuration object of your module from the > request_rec stucture. > > For the server-wide: > MyConf *cnf = (MyConf *)ap_get_module_config(r->**server->module_config, > &my_module); > > For the directory-wide: > MyConf *cnf = (MyConf *)ap_get_module_config(r->per_**dir_config, > &my_module); > > > Also, I have downloaded the 64-bit HTTP server from - >> >> http://www.apachelounge.com/**download/win64/httpd-2.4.4-**win64.zip >> >> > >> >> Is this the right official website to download Apache server? >> > > I think the official builds are downloaded from here: > http://httpd.apache.org/**download.cgi > > >> >> On Wed, May 8, 2013 at 11:04 PM, Sorin Manolache >> wrote: >> >> On 2013-05-08 17:02, Sindhi Sindhi wrote: >>> >>> Hi, >>>> >>>> I have written a C++ Apache module that performs filtering of HTML >>>> content. >>>> >>>> There are some XML files which are read by this filter when it does the >>>> filtering. During run-time when this filter is invoked, I'd want the >>>> filter >>>> pick up these XML files and read them. I was thinking these XML files >>>> can >>>> be placed in the server location "C:\Program >>>> Files\httpd-2.4.4-win64\****Apache24\htdocs\MyFilter\". where MyFilter >>>> >>>> folder >>>> will contain all the XML files needed by my filter. How do I access this >>>> location programatically during run-time when the filter is invoked? >>>> >>>> How can I get the absolute path of the server installation loacation >>>> (C:\Program Files\httpd-2.4.4-win64\****Apache24\htdocs\) so that I can >>>> >>>> append >>>> "MyFilter\" to the same to get the location of the XML files? >>>> >>>> I have specified the below in httpd.conf file: >>>> DocumentRoot "C:/Program Files/httpd-2.4.4-win64/****Apache24/htdocs" >>>> ServerRoot "C:/Program Files/httpd-2.4.4-win64/****Apache24" >>>> >>>> >>>> The signature of my filter looks like this - >>>> static apr_status_t myHtmlFilter(ap_filter_t *f, apr_bucket_brigade >>>> *pbbIn) >>>> >>>> I will need the document root or server root or any other path variable >>>> that I can access from my filter that will give me the absolute path >>>> "C:/Program Files/httpd-2.4.4-win64/****Apache24" >>>> >>>> >>> const char *ap_server_root in http_main.h (apache 2.2. It could be >>> similar >>> in 2.4) contains the ServerRoot. >>> >>> ap_server_root_relative in http_config.h allows you to compose paths >>> relative to the ServerRoot. >>> >>> Sorin >>> >>> >>> Thanks. >>>> >>>> >>>> >>> >> > --047d7b3a9baa95557804dc71b55b--