mod_musicindex  1.4.1
playlist.h File Reference
#include "mod_musicindex.h"

Go to the source code of this file.

Data Structures

struct  ftype
 struct used to associate a filetype name and its corresponding mimetype. More...
struct  mu_ent_names
 first struct to handle yet unparsed files. More...

Macros

#define NEW_ENT(pool)   ((mu_ent *)apr_pcalloc(pool, sizeof(mu_ent)))
#define P_FLAGS_OPTIONS(p, soptions)
 this is used in several places; make it a define to avoid duplicating code

Typedefs

typedef mu_ent *(* make_entry_ptr )(request_rec *, apr_pool_t *, FILE *const, const char *const)
 Function pointer type, as we need it.
typedef struct mu_ent_names mu_ent_names
 first struct to handle yet unparsed files.

Enumerations

enum  {
  FT_MP3, FT_OGG, FT_FLAC, FT_MP4,
  FT_MAX
}
 Enumerate handlers to access relevant data in struct filetype. More...

Functions

void make_music_entry (request_rec *, apr_pool_t *, mu_pack *const, mu_ent_names *, unsigned long)
 Add a file (and the content of the directory if requested) to the chain.
void build_custom_list (request_rec *, mu_pack *const)
 Creates a link list based on the custom list.

Variables

struct ftype const filetype []
 Array of common strings widely used.

Macro Definition Documentation

#define NEW_ENT (   pool)    ((mu_ent *)apr_pcalloc(pool, sizeof(mu_ent)))
#define P_FLAGS_OPTIONS (   p,
  soptions 
)
Value:
if (soptions & MI_ALLOWSTREAM) \
p->flags |= EF_ALLOWSTREAM; \
if (soptions & MI_ALLOWDWNLD) \
p->flags |= EF_ALLOWDWNLD; \
if (soptions & MI_ALLOWTARBALL) \
p->flags |= EF_ALLOWTARBALL; \
if (soptions & MI_ALLOWRSS) \
p->flags |= EF_ALLOWRSS

this is used in several places; make it a define to avoid duplicating code

Definition at line 69 of file playlist.h.

Referenced by make_music_entry(), and mysql_cache_dircontents().

Typedef Documentation

typedef mu_ent*(* make_entry_ptr)(request_rec *, apr_pool_t *, FILE *const, const char *const)

Function pointer type, as we need it.

Here comes the declaration of the funny part... We will (again) use function pointers which will allocate a new entry from the apache pool, fill it, and close the "in" file if they recognise the file.

Definition at line 29 of file playlist.h.

typedef struct mu_ent_names mu_ent_names

first struct to handle yet unparsed files.

DEV NOTE: filename is the path to the file on the filesystem, while uri is the path to the file on the webserver.

Enumeration Type Documentation

anonymous enum

Enumerate handlers to access relevant data in struct filetype.

FT_MAX is the last element of the enum, it's a marker that gives us the size of the corresponding array.

Warning
BEWARE: you must keep that in a coherent order wrt struct filetype[] !
Enumerator:
FT_MP3 
FT_OGG 
FT_FLAC 
FT_MP4 
FT_MAX 

Definition at line 40 of file playlist.h.

Function Documentation

void build_custom_list ( request_rec *  r,
mu_pack *const  pack 
)

Creates a link list based on the custom list.

This function generates a list containing all the files referenced in the conf->custom_list string. It handles parameters in a way so that it can handle indifferently strings for cookies or on-the-fly playlists.

Warning
This function uses a subrequest for each file. This has a significant performance impact, but OTOH this function isn't really in the 'performance path' of the module anyway.
Parameters
rApache request_rec struct
packA pack to which the generated list will be hooked
Returns
a list of mu_ent on success, NULL otherwise.

Definition at line 556 of file playlist.c.

References ap_sub_req_lookup_uri, apr_base64_decode, apr_base64_decode_len, mu_config::custom_list, mu_pack::fhead, mu_ent_names::filename, mu_pack::head, make_music_entry(), MI_ALLOWFETCH, MI_CUSTOM, musicindex_module, mu_ent::next, options, and mu_ent_names::uri.

Referenced by handle_musicindex().

void make_music_entry ( request_rec *  r,
apr_pool_t pool,
mu_pack *const  pack,
mu_ent_names names,
unsigned long  soptions 
)

Add a file (and the content of the directory if requested) to the chain.

This function creates a new entry from a file. If the file is a directory and the recursive option is set, all its content is also added. Otherwise, if the file is "recognized", it is simply added.

Warning
If the filename is too long, it will be ignored.
Todo:
Find a way to not delegate file closing to subsystems (essentially hack vorbis)
Bug:
I'm afraid if we're asked to recurse into too many subdirs, we might end up with too many open fdesc.
Note
It'd be very nice to be able to make this function tail recursive, unfortunately it looks like it's going to be rather troublesome to do so.
This function will NOT and should NEVER muck with mu_pack.fhead. This should be taken care of by whoever calls it.
r->filename is the path to the file on the filesystem, while r->parsed_uri.path is the path to the file on the webserver, so no assertion can be made on their respective length
Parameters
poolPool
rApache request_rec struct to handle log writings (debugging)
packA pack of music entries to populate
namesNames
soptionsbitwise special options: these are made of the extended options flag set and are used to fiddle with the algorithms (regis please docu...)
Returns
When possible, struct mu_ent correctly set up

Definition at line 307 of file playlist.c.

References mu_ent::album, ap_is_directory, ap_sub_req_lookup_uri, apr_palloc, apr_pstrdup, apr_pstrndup, mu_ent::artist, mu_config::cache, mu_dir::dir, mu_config::dir_per_line, mu_pack::dirnb, EF_INCACHE, FALSE, mu_ent::file, mu_ent_names::filename, mu_ent::filename, mu_pack::filenb, mu_ent::filetype, mu_ent::flags, mu_pack::fsize, go_through_directory(), mu_pack::head, likely, make_entry, make_music_entry(), MAX_STRING, MI_ALLOWFETCH, MI_ALLOWRSS, MI_CUSTOM, MI_QUICKPL, MI_RECURSIVE, mi_rerror, MI_RSS, MI_STREAM, MI_TARBALL, musicindex_closedir(), musicindex_module, musicindex_opendir(), musicindex_readdir(), NEW_ENT, mu_ent::next, options, mu_config::options, P_FLAGS_OPTIONS, mu_config::search, mu_ent::size, mu_ent::title, unlikely, mu_ent_names::uri, mu_ent::uri, and cache_backend::write.

Referenced by build_custom_list(), cookie_addall(), handle_musicfile(), handle_musicindex(), and make_music_entry().

Variable Documentation