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 <mookimo...@gmail.com> 
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 <stdio.h>
#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 int    refresh ;
} 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 <mookimo...@gmail.com> 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 <cove...@gmail.com> wrote:
> >
> > On Tue, Jul 30, 2019 at 11:41 AM Bill Moo <mookimo...@gmail.com> 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.

Reply via email to