mod_musicindex  1.4.1
config.c File Reference

Configuration handling and default settings. More...

#include "config.h"
#include "sort.h"

Go to the source code of this file.

Typedefs

typedef int(* cache_backend_setup )(cmd_parms *cmd, const char *setup_string, mu_config *const conf)

Functions

void * create_musicindex_config (apr_pool_t *p, char *dummy)
 Generates a per-directory configuration.
void * merge_musicindex_configs (apr_pool_t *p, void *basev, void *addv)
 Merge per-directory configurations.
static unsigned short sort_or_fields (cmd_parms *cmd, unsigned char *restrict list, const char *optstr)
static const char * sort_order (cmd_parms *cmd, void *d, const char *optstr)
static const char * set_fields (cmd_parms *cmd, void *d, const char *optstr)
static const char * basic_config (cmd_parms *cmd, void *d, const char *optstr)
 Enables the module options.
static const char * set_cache_uri (cmd_parms *cmd, void *d, const char *optstr)
 Configures the cache location in the filesystem.
static const char * set_page_title (cmd_parms *cmd, void *d, const char *optstr)
 Sets the title of the page.
static const char * set_ice_server (cmd_parms *cmd, void *d, const char *optstr)
 Sets the icecast server address.
static const char * set_css_default (cmd_parms *cmd, void *d, const char *optstr)
 Sets the default CSS file.
static const char * set_cookie_life (cmd_parms *cmd, void *d, const char *optstr)
 Sets the cookie lifetime.
static const char * set_dirperline (cmd_parms *cmd, void *d, const char *optstr)
 Sets the number of directories to display per line.
static const char * set_display (cmd_parms *cmd, void *d, const char *optstr)
 Sets the default display.

Variables

static const
cache_backend_setup const 
cache_setups []
 list of cache setup functions, to be handled manually
static const unsigned char const default_order []
 Default sort order.
static const unsigned char const default_fields []
 Default fields displayed.
static const char const default_directory [] = "/musicindex"
 Default musicindex directory.
static const char const default_rootname [] = "Music"
 Default root directory name.
static const char const default_css [] = "musicindex.css"
 Default CSS file name.
struct {
   const char *const   string
   const char   value
options []
const command_rec musicindex_cmds []

Detailed Description

Configuration handling and default settings.

Author
Regis Boudin
Thibaut Varene
Version
Revision:
1001
Date
2003-2007
2009
2012

That file takes care of the module configuration, either via setting some known default values, and/or by getting them from environmental configuration variables passed to apache in its config file.

http://www.apachetutor.org/dev/config
http://www.kuzbass.ru/docs/apache_c_mod_perl/147.htm

Definition in file config.c.

Typedef Documentation

typedef int(* cache_backend_setup)(cmd_parms *cmd, const char *setup_string, mu_config *const conf)

Definition at line 53 of file config.c.

Function Documentation

static const char* basic_config ( cmd_parms *  cmd,
void *  d,
const char *  optstr 
)
static

Enables the module options.

Read the different options given as parameters, and set the various flags.

Parameters
cmdI don't use it.
dPointer to configuration structure.
optstrThe string given as parameter in the configuration.
Returns
NULL don't ask why.

Definition at line 291 of file config.c.

References CONF_RSS_ITEMS, MI_ACTIVE, MI_ALLOWDWNLD, MI_ALLOWSEARCH, MI_ALLOWSTREAM, MI_ALLOWTARBALL, mu_config::options, mu_config::options_not, and mu_config::rss_items.

void* create_musicindex_config ( apr_pool_t p,
char *  dummy 
)

Generates a per-directory configuration.

This function creates a new configuration structure and fills it with default values.

Note
It kinda bugs me that we don't need to set options_not = ~0, but it seems to work without it...
Parameters
pApache pool for memory allocation.
dummystring containing the path to the relevant Directory or Location - we don't use it.
Returns
The newly created configuration structure.

Definition at line 108 of file config.c.

References apr_pcalloc, CONF_COOKIE_LIFE, CONF_DIRPERLINE, default_css, default_directory, default_fields, default_order, and default_rootname.

void* merge_musicindex_configs ( apr_pool_t p,
void *  basev,
void *  addv 
)

Merge per-directory configurations.

This function is supposed to merge two per-directory configurations. We apply a simple inheritance pattern from the parent directory(ies).

Note
In the absence of a .htaccess in the hierarchy of folders being accessed, #basev contains a freshly created config structure (through create_musicindex_config()) and #addv contains another config struct created through create_musicindex_config(), with the configuration parameters modified by <Directory> directive (if any) set appropriately.
#basev: clean #addv: configured => keep #addv
In the presence of a .htaccess file in the directory being accessed, #basev contains the result of the merging of all "parent" configuration directives (<Directory> being the top ancestor, and any subsquent .htaccess being merged using merge_musicindex_configs()) up to the one in the current directory being accessed, which config options are set in #addv.
#basev: merged #addv: configured => merge
In the presence of a .htaccess anywhere in the parent hierarchy of the directory being accessed BUT in said directory, #basev contains a pristine config structure (as per create_musicindex_config()) and #addv contains the result of merging all parent configuration directives (<Directory> being the top ancestor).
#basev: clean #addv: merged => keep #addv

Hence the logic of this function: if #basev contains init data (data setup in create_musicindex_config()), use #addv element. Otherwise, merge both configs.

Parameters
pApache pool for memory allocation.
basevPointer to main configuration structure.
addvPointer to parent dir configuration structure,
Returns
The newly created configuration structure.

Definition at line 161 of file config.c.

References apr_pcalloc, CF_CACHE, CF_CKLF, CF_CSS, CF_DPL, CF_FIELDS, CF_ICES, CF_MERGED, CF_ORDER, CF_RSS, CF_TITLE, and default_directory.

static const char* set_cache_uri ( cmd_parms *  cmd,
void *  d,
const char *  optstr 
)
static

Configures the cache location in the filesystem.

This function sets the configuration string for the cache subsystem.

Parameters
cmdStruct containing a pointer to the pool I have to use.
dPointer to configuration structure.
optstrThe string given as parameter in the configuration.
Returns
NULL don't ask why.

Definition at line 360 of file config.c.

References cache_setups, CF_CACHE, and mu_config::sets.

static const char* set_cookie_life ( cmd_parms *  cmd,
void *  d,
const char *  optstr 
)
static

Sets the cookie lifetime.

This function sets the lifetime in seconds of the cookie used for custom playlist constructs.

Parameters
cmdI don't use it.
dPointer to configuration structure.
optstrThe string given as parameter in the configuration.
Returns
NULL don't ask why.

Definition at line 441 of file config.c.

References CF_CKLF, mu_config::cookie_life, and mu_config::sets.

static const char* set_css_default ( cmd_parms *  cmd,
void *  d,
const char *  optstr 
)
static

Sets the default CSS file.

This function sets which CSS file will be used by default

Parameters
cmdStruct containing a pointer to the pool I have to use.
dPointer to configuration structure.
optstrThe string given as parameter in the configuration.
Returns
NULL don't ask why.

Definition at line 422 of file config.c.

References apr_pstrdup, CF_CSS, mu_config::css, and mu_config::sets.

static const char* set_dirperline ( cmd_parms *  cmd,
void *  d,
const char *  optstr 
)
static

Sets the number of directories to display per line.

Negative values will disable the "pretty folders" system.

Parameters
cmdI don't use it.
dPointer to configuration structure.
optstrThe string given as parameter in the configuration.
Returns
NULL don't ask why.

Definition at line 459 of file config.c.

References CF_DPL, CONF_DIRPERLINE, mu_config::dir_per_line, and mu_config::sets.

static const char* set_display ( cmd_parms *  cmd,
void *  d,
const char *  optstr 
)
static

Sets the default display.

Bug:
Wouldn't this override whatever is set with MusicSortOrder?
Parameters
cmdStruct containing a pointer to the pool I have to use.
dPointer to configuration structure.
optstrThe string given as parameter in the configuration.
Returns
NULL don't ask why.

Definition at line 478 of file config.c.

References CF_ORDER, CF_RSS, CONF_RSS_ITEMS, default_order, MI_RECURSIVE, MI_RSS, mu_config::options, mu_config::options_not, mu_config::order, mu_config::rss_items, SB_MTIME, SB_URI, and mu_config::sets.

static const char* set_fields ( cmd_parms *  cmd,
void *  d,
const char *  optstr 
)
static

Definition at line 272 of file config.c.

References CF_FIELDS, mu_config::fields, mu_config::sets, and sort_or_fields().

static const char* set_ice_server ( cmd_parms *  cmd,
void *  d,
const char *  optstr 
)
static

Sets the icecast server address.

This function sets an icecast server for streaming.

Parameters
cmdStruct containing a pointer to the pool I have to use.
dPointer to configuration structure.
optstrThe string given as parameter in the configuration.
Returns
NULL don't ask why.

Definition at line 404 of file config.c.

References apr_pstrdup, CF_ICES, mu_config::iceserver, and mu_config::sets.

static const char* set_page_title ( cmd_parms *  cmd,
void *  d,
const char *  optstr 
)
static

Sets the title of the page.

This function simply chages the name of the root.

Parameters
cmdStruct containing a pointer to the pool I have to use.
dPointer to configuration structure.
optstrThe string given as parameter in the configuration.
Returns
NULL don't ask why.

Definition at line 383 of file config.c.

References apr_pstrdup, CF_TITLE, mu_config::sets, and mu_config::title.

static unsigned short sort_or_fields ( cmd_parms *  cmd,
unsigned char *restrict  list,
const char *  optstr 
)
static

Definition at line 244 of file config.c.

References options, and SB_MAX.

Referenced by set_fields(), and sort_order().

static const char* sort_order ( cmd_parms *  cmd,
void *  d,
const char *  optstr 
)
static

Definition at line 263 of file config.c.

References CF_ORDER, mu_config::order, SB_URI, mu_config::sets, and sort_or_fields().

Variable Documentation

const cache_backend_setup const cache_setups[]
static
Initial value:
{
NULL
}

list of cache setup functions, to be handled manually

Definition at line 56 of file config.c.

Referenced by set_cache_uri().

const char const default_css[] = "musicindex.css"
static

Default CSS file name.

Definition at line 92 of file config.c.

Referenced by create_musicindex_config().

const char const default_directory[] = "/musicindex"
static

Default musicindex directory.

Definition at line 90 of file config.c.

Referenced by create_musicindex_config(), and merge_musicindex_configs().

const unsigned char const default_fields[]
static
Initial value:

Default fields displayed.

Definition at line 82 of file config.c.

Referenced by create_musicindex_config().

const unsigned char const default_order[]
static
Initial value:

Default sort order.

Definition at line 67 of file config.c.

Referenced by create_musicindex_config(), and set_display().

const char const default_rootname[] = "Music"
static

Default root directory name.

Definition at line 91 of file config.c.

Referenced by create_musicindex_config().

const command_rec musicindex_cmds[]
Initial value:
{
AP_INIT_RAW_ARGS("MusicIndex", basic_config, NULL, OR_INDEXES,
"can be : On/Off +/-Stream +/-Download +/-Search +/-Rss"),
AP_INIT_RAW_ARGS("MusicSortOrder", sort_order, NULL, OR_INDEXES,
"can be : title album artist track disc length bitrate filetype genre filename date uri"),
AP_INIT_RAW_ARGS("MusicFields", set_fields, NULL, OR_INDEXES,
"can be : title album artist track disc length bitrate filetype genre filename date"),
AP_INIT_RAW_ARGS("MusicIndexCache", set_cache_uri, NULL, ACCESS_CONF,
"Set the cache configuration string"),
AP_INIT_RAW_ARGS("MusicPageTitle", set_page_title, NULL, OR_INDEXES,
"Set the root title of the page."),
AP_INIT_TAKE1("MusicIceServer", set_ice_server, NULL, ACCESS_CONF,
"Set the icecast server address : [server.domain.org]:8000"),
AP_INIT_TAKE1("MusicDefaultCss", set_css_default, NULL, OR_INDEXES,
"Set the default CSS file"),
AP_INIT_TAKE1("MusicCookieLife", set_cookie_life, NULL, ACCESS_CONF,
"Set the lifetime (in seconds) of the cookie sent for custom playlists"),
AP_INIT_TAKE1("MusicDefaultDisplay", set_display, NULL, ACCESS_CONF,
"Set the default display returned by the module (HTML or RSS)"),
AP_INIT_TAKE1("MusicDirPerLine", set_dirperline, NULL, OR_INDEXES,
"Set the number of directories per line in the directory listing"),
{NULL}
}

Definition at line 499 of file config.c.

struct { ... } options[]
const char* const string

Definition at line 224 of file config.c.

const char value

Definition at line 225 of file config.c.