Main Page   Data Structures   File List   Data Fields   Globals  

mod_countm.c File Reference

countm module routines More...

#include <httpd.h>
#include <http_config.h>
#include <http_core.h>
#include <http_log.h>
#include <apr_strings.h>
#include <apr_lib.h>
#include <apr_file_io.h>
#include <apr_file_info.h>
#include <apr_pools.h>
#include <http_protocol.h>
#include <gd.h>
#include <db.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>

Namespaces

namespace  Countm

Data Structures

struct  countent
struct  countm_config
 per-server-configuration information More...

struct  db_count_record
 the structure stored in DB_COUNT More...

struct  rgb

Defines

#define DEFAULT_LOCKFILE_STRING   "/var/countm/countm.lock"
 Default countm lockfile. When file exists, indicates database is locked, and in use. Define as an absolute path/filename. May not be the empty string.

#define DEFAULT_FONTSDIR_STRING   "/var/countm/fonts"
 Default countm fonts directory. Specifies the directory containing the true type fonts countm may use. Must be and absolute path. May not be the empty string (which is an error). Finally, a / must not end the string.

#define DEFAULT_FONT_STRING   "FreeMono"
 Defalut countm font. Must be defined as a valid filename. Do not include the .ttf extension suffix. Is considered relative to DEFAULT_FONTSDIR_STRING. A '/' should not begin the name.

#define DEFAULT_DB_ENVIRONMENT_HOME_STRING   "/var/countm/dbase"
 The directory containing database infomation. Must be absolute. A '/' should not end the path.

#define DEFAULT_DB_FILE_STRING   "countm.db"
 The database file of link access hostnames. Relative to the DEFAULT_DB_ENVIRONMENT_HOME_STRING directory. May not be empty string.

#define DEFAULT_DB_LOG_FILE_STRING   "/var/countm/dbase/db.log"
 The database log file. Must be absolute. May not be empty string.

#define DB_ERROR_LOG_PREFIX_STRING   "dba_err"
 The prefix used when writing database errors.

#define DB_COUNTER   "DB_COUNTER"
 The internal name of the counter database.

#define DB_ACCESS   "DB_ACCESS"
 The internal name of the access database.

#define MODULE_URI_PATH_STRING   "/countm"
 The match string for the URI path. Must begin with a /, and be a valid path name. Only alter if absolutely necessary. Matches the directory specified in the <Location> directive.

#define MODULE_HANDLER_ID_STRING   "mod-countm"
 The AddHandler string in the config file Matches the handler string to the module. Only alter if absolutely necessary.

#define USE_REMOTE_DOUBLE_REV
 If hostname lookup fails, attempts to use double reverse If get_remote_host fails to return a valid hostname, an additional call using REMOTE_DOUBLE_REV will be attempted. To deactivate, comment out the define.

#define UNLOCK_ATTEMPTS   3
 The number of database unlock attempts each request tries. If the database may not be unlocked, the request sleeps for a second and tries again. After each attempt, it waits for 1 second.


Typedefs

typedef unsigned long cntval_t
 The type for the counter value.


Functions

void * countm_per_server_config (apr_pool_t *p, server_rec *s)
 Server startup configuration routine.

int countm_method_handler (request_rec *r)
 Handler for the method. Processes the request given in r->args into parameters, and completes request.

void countm_register_hooks (apr_pool_t *p)
 Registers required hooks. Called by API to register hooks necessary for various stages.

int lock (const char *const sza_fn, apr_pool_t *p)
 Locks the database. Locks the database by creating a lock file.

int unlock (const char *const sza_fn, apr_pool_t *p)
 Unlocks the database. Unlocks the database by removing the lock file.

void rgb_color (const char *hexnum, struct rgb *rgb)
 Manipulates rgb color values.

int display_string (const char *sza_string, struct countent *ce, request_rec *r)
 displays the counter back to the requesting client.

DB_ENV * db_env_init (const char *home, const char *prefix, int cachesize, FILE *fp_log)
 Initialize the database environment.

DB * db_open (DB_ENV *dbenv, const char *fname, const char *dname, DBTYPE dtype, u_int32_t dflags_open, u_int32_t dflags_db, int dmode, u_int32_t dpgsize)
int countm_hook_post_config (apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s)
 The post configuation hook. Assigns default values to parameters not given in the httpd.conf file, and verifies that required files exist, and are accessable. How return failure, and abort module loading?


Detailed Description

countm module routines


Define Documentation

#define DEFAULT_FONT_STRING   "FreeMono"
 

Defalut countm font. Must be defined as a valid filename. Do not include the .ttf extension suffix. Is considered relative to DEFAULT_FONTSDIR_STRING. A '/' should not begin the name.

Warning:
The font file must be in fontsdir, or, when module is loaded, an error is returned.

#define DEFAULT_LOCKFILE_STRING   "/var/countm/countm.lock"
 

Default countm lockfile. When file exists, indicates database is locked, and in use. Define as an absolute path/filename. May not be the empty string.

Warning:
if file exists when module loaded an error is returned.

#define INITIALIZE_COUNTENT
 

Value:

{ \
    NULL, NULL,0, 1, 0, 0, -1, 20, \
    {0, 0, 0}, \
    {255, 255, 255}, \
    NULL, NULL, 0, -1, -1, -1, 0 \
  }


Function Documentation

countm_hook_post_config apr_pool_t *    pconf,
apr_pool_t *    plog,
apr_pool_t *    ptemp,
server_rec *    s
[static]
 

The post configuation hook. Assigns default values to parameters not given in the httpd.conf file, and verifies that required files exist, and are accessable. How return failure, and abort module loading?

Parameters:
pconf  The configuration pool.
plog  The log pool (whatever that is)??.
ptemp  The temporary pool. Created at the beginning of configuration cycle, and exists until the end of config parsing (same as cmd->temp_pool).
s  Server record.
Returns:
Message code. What are the possible values?

int countm_method_handler request_rec *    r [static]
 

Handler for the method. Processes the request given in r->args into parameters, and completes request.

Parameters:
r  The request record of the method.
Returns:
Status value. Possible values are?

void * countm_per_server_config apr_pool_t *    p,
server_rec *    s
[static]
 

Server startup configuration routine.

Parameters:
p  The configuration pool. Exists till server shutdown.
s  The server record.
Returns:
Pointer to the module_config record. What happens if return NULL?

void countm_register_hooks apr_pool_t *    p [static]
 

Registers required hooks. Called by API to register hooks necessary for various stages.

Parameters:
p  The memory pool. The pconf, ptemp, or other pool?
Returns:
none

DB_ENV * db_env_init const char *    home,
const char *    prefix,
int    cachesize,
FILE *    fp_log
[static]
 

Initialize the database environment.

Parameters:
home  The environment home.
prefix  The prefix for the error log.
cachesize  The cachesize for the database.
fp_log  The FILE * to the error log for the database.
Returns:
NULL=error, dbenv if successful

DB * db_open DB_ENV *    dbenv,
const char *    fname,
const char *    dname,
DBTYPE    dtype,
u_int32_t    dflags_open,
u_int32_t    dflags_db,
int    dmode,
u_int32_t    dpgsize
[static]
 

@breif Opens a database

Parameters:
dbenv  The environment to open in (returned from db_env_init)
dname  The internal database name.
dtype  The data base type.
dflags_open  The open database flags.
dflags_db  The database flags (DB->set_flags).
dmode  The file creation mode (0664 normal)
dpgsize  The page size for the database (DB->set_page_size)
Returns:
NULL=Error, dbp=Success.

int display_string const char *    sza_display,
struct countent *    ce,
request_rec *    r
[static]
 

displays the counter back to the requesting client.

Parameters:
sza_display  The string to send.
ce  The countent structure with data for request.
r  The request record for this request.
Returns:
Status code.

int lock const char *const    sza_fn,
apr_pool_t *    p
[static]
 

Locks the database. Locks the database by creating a lock file.

Parameters:
sza_fn  The name of the lockfile to create.
p  The pool to allocate memory from.
Returns:
1=Success 0=Failure.

void rgb_color const char *    hexnum,
struct rgb *    rgb
[static]
 

Manipulates rgb color values.

Parameters:
hexnum  String representing 6 consecutive hex digits.
rgb  Pointer to allocated return structure.
Returns:
The colors represented by the rgb structure.

int unlock const char *const    sza_fn,
apr_pool_t *    p
[static]
 

Unlocks the database. Unlocks the database by removing the lock file.

Parameters:
sza_fn  The name of the lockfile to remove.
p  The pool to allocate memory from.
Returns:
1=Success 0=Failure.


Variable Documentation

command_rec countm_cmds[]
 

Initial value:

{
  AP_INIT_TAKE1("CountmLockfile", set_lockfile, NULL, RSRC_CONF,
                "the name of the countm database lockfile"),

  AP_INIT_TAKE1("CountmFontDir", set_fontsdir, NULL, RSRC_CONF,
                "the name of the countm font directory"),

  AP_INIT_TAKE1("CountmDefFont", set_font, NULL, RSRC_CONF,
                "the name of the default countm font"),

  AP_INIT_TAKE1("CountmEnvironmentHome", set_db_environment_home, NULL,
                RSRC_CONF, "the name of the countm database directory"),

  AP_INIT_TAKE1("CountmDB", set_db_file, NULL, RSRC_CONF,
                "the name of the countm database file"),
  
  AP_INIT_TAKE1("CountmDBLog", set_db_log_file, NULL, RSRC_CONF,
                "the name of the countm database log file"),
  
  {NULL}
}

module AP_MODULE_DECLARE_DATA countm_module
 

Initial value:

  {
    STANDARD20_MODULE_STUFF,
    NULL,
    NULL,
    countm_per_server_config,
    NULL,
    countm_cmds,
    countm_register_hooks
  }

const char sza_def_db_environment_home[] [static]
 

Initial value:


Generated on Mon Nov 10 09:22:53 2003 for odometer by doxygen1.2.18