Re: [EXTERNAL] Re: No content returned from directive handler sample.

2019-07-31 Thread Bill Moo
For those interested I have now fixed this thanks to a bit of logging
and the culprit was in fact this line:

if(!r->handler || strcmp(r->handler, "configHandler")) return(DECLINED);

the string being offered in the r->handler was in fact confighandler
so the comparison was failing and declining the offer!

On Wed, 31 Jul 2019 at 07:11, Bill Moo  wrote:
>
> No I hadn't so thank you Christopher.
>
> On Tue, 30 Jul 2019 at 17:37, Nebergall, Christopher
>  wrote:
> >
> > Have you seen this example?
> >
> > https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x/modules/examples/mod_example_hooks.c
> >
> > It will show you how to log at the very least.
> >
> > -Topher
> > -Original Message-
> > From: Bill Moo 
> > Sent: Tuesday, July 30, 2019 11:06 AM
> > To: modules-dev@httpd.apache.org
> > Subject: [EXTERNAL] Re: No content returned from directive handler sample.
> >
> > If it help anyone then here if the code I am using:
> >
> > /* module mod_graphing.c: */
> > #include 
> > #include "apr_hash.h"
> > #include "ap_config.h"
> > #include "ap_provider.h"
> > #include "httpd.h"
> > #include "http_core.h"
> > #include "http_config.h"
> > #include "http_log.h"
> > #include "http_protocol.h"
> > #include "http_request.h"
> >
> > extern module mod_graphing ;
> >
> > /* Struct used to store template settings for a graph */ typedef struct {
> > const char *m_Name ;
> > const char *m_Template ;
> > unsigned intrefresh ;
> > } PROCEDURE ;
> >
> > /* Our configuration prototype and declaration: */ typedef struct {
> > const char *m_SQL ; /* SQL Connection String */
> > const char *m_Usr ; /* SQL User name */
> > const char *m_Pwd ; /* SQL Password */
> > unsigned long   m_Port ; /* Port No */
> > PROCEDURE * m_Procs ;/* Array of Procedure Structures */ } CONFIG ;
> >
> > static int configHandler(request_rec *) ; const char * 
> > configSetSQL(cmd_parms *, void *, const char *) ; const char * 
> > configSetPort(cmd_parms *, void *, const char *) ; //const char * 
> > configSetPort(cmd_parms *, void *, const unsigned long *) ; const char * 
> > configSetSQLUser(cmd_parms *, void *, const char *, const char *) ; static 
> > void register_hooks(apr_pool_t *) ;
> >
> > static CONFIG Config;
> >
> > /* Handler for the "examplePath" directive */ const char * 
> > configSetSQL(cmd_parms * cmd, void * cfg, const char * arg) {
> > Config.m_SQL = arg ;
> > return NULL ;
> > }
> >
> > const char * configSetPort(cmd_parms * cmd, void * cfg, const char * arg) {
> > Config.m_Port = atol(arg) ;
> > return NULL ;
> > }
> >
> > const char * configSetSQLUser(cmd_parms * cmd, void * cfg, const char
> > * usr, const char * pwd) {
> > Config.m_Usr = usr ;
> > Config.m_Pwd = pwd ;
> > return NULL ;
> > }
> >
> > /* The directive structure for our name tag: */ extern const command_rec 
> > configDirectives[] = {
> > AP_INIT_TAKE1("sqlConnection", configSetSQL, NULL, ACCESS_CONF, "Set 
> > the PostgreSQL Connection"),
> > AP_INIT_TAKE1("sqlPortNo”, configSetPort, NULL, ACCESS_CONF, "Set SQL 
> > Port No”),
> > AP_INIT_TAKE2("sqlUserInfo", configSetSQLUser, NULL, ACCESS_CONF, "Set 
> > PostgreSQL Username / Password"),
> > { NULL }
> > };
> >
> > /* Our module handler: */
> > static int configHandler(request_rec *r) {
> > if(!r->handler || strcmp(r->handler, "configHandler")) return(DECLINED);
> > ap_set_content_type(r, "text/plain");
> > ap_rprintf(r, "User IP : %s", r->useragent_ip) ;
> > ap_rprintf(r, "SQL Conn : %s", Config->m_SQL) ;
> > ap_rprintf(r, "SQL User : %s, %s", Config->m_Usr, Config->m_Pwd) ;
> > ap_rprintf(r, “Port No : %ul", Config->m_Port) ;
> > return OK;
> > };
> >
> > /* The hook registration function (also initializes the default config
> > values): */
> > static void register_hooks(apr_pool_t *pool) {
> > Config.m_SQL = NULL ;
> > Config.m_Usr = NULL ;
> > Config.m_Pwd = NULL ;
> > Config.m_Port = 0 ;
> > Config.m_Procs = NULL ;
> > ap_hook_handler(configHandler, NULL, NULL, APR_HOOK_LAST

RE: [EXTERNAL] Re: No content returned from directive handler sample.

2019-07-30 Thread Nebergall, Christopher
Have you seen this example?

https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x/modules/examples/mod_example_hooks.c

It will show you how to log at the very least.

-Topher
-Original Message-
From: Bill Moo  
Sent: Tuesday, July 30, 2019 11:06 AM
To: modules-dev@httpd.apache.org
Subject: [EXTERNAL] Re: No content returned from directive handler sample.

If it help anyone then here if the code I am using:

/* module mod_graphing.c: */
#include 
#include "apr_hash.h"
#include "ap_config.h"
#include "ap_provider.h"
#include "httpd.h"
#include "http_core.h"
#include "http_config.h"
#include "http_log.h"
#include "http_protocol.h"
#include "http_request.h"

extern module mod_graphing ;

/* Struct used to store template settings for a graph */ typedef struct {
const char *m_Name ;
const char *m_Template ;
unsigned intrefresh ;
} PROCEDURE ;

/* Our configuration prototype and declaration: */ typedef struct {
const char *m_SQL ; /* SQL Connection String */
const char *m_Usr ; /* SQL User name */
const char *m_Pwd ; /* SQL Password */
unsigned long   m_Port ; /* Port No */
PROCEDURE * m_Procs ;/* Array of Procedure Structures */ } CONFIG ;

static int configHandler(request_rec *) ; const char * configSetSQL(cmd_parms 
*, void *, const char *) ; const char * configSetPort(cmd_parms *, void *, 
const char *) ; //const char * configSetPort(cmd_parms *, void *, const 
unsigned long *) ; const char * configSetSQLUser(cmd_parms *, void *, const 
char *, const char *) ; static void register_hooks(apr_pool_t *) ;

static CONFIG Config;

/* Handler for the "examplePath" directive */ const char * 
configSetSQL(cmd_parms * cmd, void * cfg, const char * arg) {
Config.m_SQL = arg ;
return NULL ;
}

const char * configSetPort(cmd_parms * cmd, void * cfg, const char * arg) {
Config.m_Port = atol(arg) ;
return NULL ;
}

const char * configSetSQLUser(cmd_parms * cmd, void * cfg, const char
* usr, const char * pwd) {
Config.m_Usr = usr ;
Config.m_Pwd = pwd ;
return NULL ;
}

/* The directive structure for our name tag: */ extern const command_rec 
configDirectives[] = {
AP_INIT_TAKE1("sqlConnection", configSetSQL, NULL, ACCESS_CONF, "Set the 
PostgreSQL Connection"),
AP_INIT_TAKE1("sqlPortNo”, configSetPort, NULL, ACCESS_CONF, "Set SQL Port 
No”),
AP_INIT_TAKE2("sqlUserInfo", configSetSQLUser, NULL, ACCESS_CONF, "Set 
PostgreSQL Username / Password"),
{ NULL }
};

/* Our module handler: */
static int configHandler(request_rec *r) {
if(!r->handler || strcmp(r->handler, "configHandler")) return(DECLINED);
ap_set_content_type(r, "text/plain");
ap_rprintf(r, "User IP : %s", r->useragent_ip) ;
ap_rprintf(r, "SQL Conn : %s", Config->m_SQL) ;
ap_rprintf(r, "SQL User : %s, %s", Config->m_Usr, Config->m_Pwd) ;
ap_rprintf(r, “Port No : %ul", Config->m_Port) ;
return OK;
};

/* The hook registration function (also initializes the default config
values): */
static void register_hooks(apr_pool_t *pool) {
Config.m_SQL = NULL ;
Config.m_Usr = NULL ;
Config.m_Pwd = NULL ;
Config.m_Port = 0 ;
Config.m_Procs = NULL ;
ap_hook_handler(configHandler, NULL, NULL, APR_HOOK_LAST); };

/* Our module name tag: */
module AP_MODULE_DECLARE_DATA mod_graphing = {
STANDARD20_MODULE_STUFF,
NULL,   /* Per-directory configuration handler */
NULL,   /* Merge handler for per-directory configurations */
NULL,   /* Per-server configuration handler */
NULL,   /* Merge handler for per-server configurations */
configDirectives, /* Any directives we may have for httpd */
register_hooks  /* Our hook registering function */
};

Apologies for polluting the thread with this.

On Tue, 30 Jul 2019 at 16:55, Bill Moo  wrote:
>
> Well I have tired what you suggested Eric but to no avail so 
> regrettably no further forward. I have even tried several variations 
> in both the Location and Directory entries.
>
> The Apache2 install I have is stock on Ubuntu 18.04 so I don't think 
> there are any proxying modules in place.
>
> Can you, or indeed anyone, tell me how I can write 'debug' output to 
> either the console or one of the Apache logs please. If I can do this 
> I'll at least be able to see if my code is being called prior to the 
> DECLINE.
>
> On Tue, 30 Jul 2019 at 16:44, Eric Covener  wrote:
> >
> > On Tue, Jul 30, 2019 at 11:41 AM Bill Moo  wrote:
> > >
> > > Hey, thanks for the quick reply. But I'll be honest and confess to 
> > > not knowing exactly what you are meaning. If I do understand 
> > > 

Re: No content returned from directive handler sample.

2019-07-30 Thread Bill Moo
Well I have tired what you suggested Eric but to no avail so
regrettably no further forward. I have even tried several variations
in both the Location and Directory entries.

The Apache2 install I have is stock on Ubuntu 18.04 so I don't think
there are any proxying modules in place.

Can you, or indeed anyone, tell me how I can write 'debug' output to
either the console or one of the Apache logs please. If I can do this
I'll at least be able to see if my code is being called prior to the
DECLINE.

On Tue, 30 Jul 2019 at 16:44, Eric Covener  wrote:
>
> On Tue, Jul 30, 2019 at 11:41 AM Bill Moo  wrote:
> >
> > Hey, thanks for the quick reply. But I'll be honest and confess to not
> > knowing exactly what you are meaning. If I do understand correctly
> > then the Location is correct but the Directory entry needs to be
> > /var/www/html/info is this correct?
>
> Yes, it should be a full filesystem path  -- if you need that kind of
> section at all.
> 2nd caveat -- proxy-like modules can short-circuit the mapping
> altogether and no directory section may match.


Re: No content returned from directive handler sample.

2019-07-30 Thread Eric Covener
On Tue, Jul 30, 2019 at 11:41 AM Bill Moo  wrote:
>
> Hey, thanks for the quick reply. But I'll be honest and confess to not
> knowing exactly what you are meaning. If I do understand correctly
> then the Location is correct but the Directory entry needs to be
> /var/www/html/info is this correct?

Yes, it should be a full filesystem path  -- if you need that kind of
section at all.
2nd caveat -- proxy-like modules can short-circuit the mapping
altogether and no directory section may match.


Re: No content returned from directive handler sample.

2019-07-30 Thread Bill Moo
Hey, thanks for the quick reply. But I'll be honest and confess to not
knowing exactly what you are meaning. If I do understand correctly
then the Location is correct but the Directory entry needs to be
/var/www/html/info is this correct?

On Tue, 30 Jul 2019 at 16:17, Eric Covener  wrote:
>
> On Tue, Jul 30, 2019 at 11:07 AM Bill Moo  wrote:
> >
> > Hello,
> >
> > I am embarking on my first module and using the Apache provided
> > example to dump my module's configuration as my starting point I’m
> > having no real success.
> >
> > I have configured everything as per the sample and compiled and
> > configured using:
> >
> > sudo apxs -i -a -n mod_graphing -c mod_graphing.c
> >
> > I have to provide the -n mod_graphing parameter as without it I get :
> > apxs:Error: Sorry, cannot determine bootstrap symbol name.
> >
> > The name (mod_graphing) being the same as the module tag. In addition
> > to this when I try to restart the server I get a Syntax error on the
> > generated mod_graphing.load file as it has appended _module to my
> > mod_graphing!
> >
> > Assuming my interpretation is correct I created a mod_graphing.conf
> > file and added to it:
> >
> > 
> > SetHandler configHandler
> > 
> >
> > 
> > sqlConnection "SQL Connection String"
> > sqlUserInfo username password
> > 
>
> Does something cause the /info URL to be mapped to the actual
> directory /info?  It looks like it should be a filesystem path in the
> latter.


Re: No content returned from directive handler sample.

2019-07-30 Thread Eric Covener
On Tue, Jul 30, 2019 at 11:07 AM Bill Moo  wrote:
>
> Hello,
>
> I am embarking on my first module and using the Apache provided
> example to dump my module's configuration as my starting point I’m
> having no real success.
>
> I have configured everything as per the sample and compiled and
> configured using:
>
> sudo apxs -i -a -n mod_graphing -c mod_graphing.c
>
> I have to provide the -n mod_graphing parameter as without it I get :
> apxs:Error: Sorry, cannot determine bootstrap symbol name.
>
> The name (mod_graphing) being the same as the module tag. In addition
> to this when I try to restart the server I get a Syntax error on the
> generated mod_graphing.load file as it has appended _module to my
> mod_graphing!
>
> Assuming my interpretation is correct I created a mod_graphing.conf
> file and added to it:
>
> 
> SetHandler configHandler
> 
>
> 
> sqlConnection "SQL Connection String"
> sqlUserInfo username password
> 

Does something cause the /info URL to be mapped to the actual
directory /info?  It looks like it should be a filesystem path in the
latter.