mod_musicindex
1.4.1
|
Playlist management system. More...
#include "playlist.h"
#include "sort.h"
#include "playlist-flac.h"
#include "playlist-vorbis.h"
#include "playlist-mp3.h"
#include "playlist-mp4.h"
#include <stdio.h>
Go to the source code of this file.
Data Structures | |
struct | mu_dir |
Wrapper struct for the cache subsystem. More... |
Typedefs | |
typedef struct mu_dir | mu_dir |
Wrapper struct for the cache subsystem. |
Functions | |
static mu_ent * | make_no_entry (request_rec *r, apr_pool_t *pool, FILE *const in, const char *const filename) |
Fallback function if the file could not be recognised. | |
static mu_ent * | make_cache_entry (request_rec *r, apr_pool_t *pool, FILE *const in, const char *const filename) |
Wrapper function to call the actual cache backend. | |
static void | musicindex_opendir (request_rec *r, mu_dir *dir, mu_pack *const pack, const mu_ent_names *const names, unsigned long soptions) |
Custom directory opener. | |
static const char * | musicindex_readdir (request_rec *r, mu_dir *dir) |
Get the string of the next filename to open. | |
static void | musicindex_closedir (request_rec *r, mu_dir *dir) |
Close the open directory. | |
static short | go_through_directory (request_rec *r, const unsigned short local_options) |
Check lots of details that could mean we shouldn't go through the directory. | |
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. | |
void | build_custom_list (request_rec *r, mu_pack *const pack) |
Creates a link list based on the custom list. |
Variables | |
struct ftype const | filetype [] |
Array of common strings widely used. | |
static const make_entry_ptr const | make_entry [] |
Function pointers array. |
Playlist management system.
This is where the magic takes place. Here are the functions in charge of analyzing the content of the folders requested by the client, and of generating the structures and lists that will be used by the HTML subsystem to generate the pretty output.
Definition in file playlist.c.
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.
r | Apache request_rec struct |
pack | A pack to which the generated list will be hooked |
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().
|
inlinestatic |
Check lots of details that could mean we shouldn't go through the directory.
r | Apache current request |
local_options | This function can be called in subdirectories for which the configuration can differ from the current dir's one. This paramater allows the caller to specify the options to check against. |
Definition at line 254 of file playlist.c.
References FALSE, MI_ACTIVE, MI_ALLOWSEARCH, MI_ALLOWSTREAM, MI_STREAMALL, musicindex_module, mu_config::options, mu_config::search, and TRUE.
Referenced by make_music_entry().
|
static |
Wrapper function to call the actual cache backend.
r | Apache request_rec struct |
pool | Apache memory pool |
in | file to parse (closed on normal exit) |
filename | current filename |
Definition at line 100 of file playlist.c.
References mu_config::cache, EF_INCACHE, mu_ent::flags, likely, cache_backend::make_entry, and musicindex_module.
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.
pool | Pool |
r | Apache request_rec struct to handle log writings (debugging) |
pack | A pack of music entries to populate |
names | Names |
soptions | bitwise special options: these are made of the extended options flag set and are used to fiddle with the algorithms (regis please docu...) |
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().
|
inlinestatic |
Fallback function if the file could not be recognised.
r | Apache request_rec struct |
pool | Pool |
in | file to parse (closed on normal exit) |
filename | current filename |
Definition at line 83 of file playlist.c.
|
inlinestatic |
Close the open directory.
r | Apache request_rec struct |
dir | Abstract pointer to our custom directory handler |
Definition at line 231 of file playlist.c.
References mu_config::cache, cache_backend::closedir, mu_dir::dir, mu_dir::handled, and musicindex_module.
Referenced by make_music_entry().
|
inlinestatic |
Custom directory opener.
This is a first shot at the custom opendir function. At the end, This wraps around the various caches for directory management. Depending on what the cache back-end can do, it may add things to the entries list, and generate an internal list of files left to deal with. These files names will be retrieved with musicindex_readdir(). We mimic the opendir()/readdir()/closedir() scheme.
r | the Apache request |
dir | Abstract pointer to our custom directory handler |
pack | pack pointer |
names | structure containing the name of the directory |
soptions | the current extended options |
Definition at line 172 of file playlist.c.
References mu_config::cache, mu_dir::dir, mu_ent_names::filename, mu_dir::handled, musicindex_module, cache_backend::opendir, and mu_ent_names::uri.
Referenced by make_music_entry().
|
inlinestatic |
Get the string of the next filename to open.
r | Apache request_rec struct |
dir | Abstract pointer to our custom directory handler |
Definition at line 203 of file playlist.c.
References mu_config::cache, mu_dir::dir, mu_dir::handled, musicindex_module, and cache_backend::readdir.
Referenced by make_music_entry().
struct ftype const filetype[] |
Array of common strings widely used.
http://filext.com/detaillist.php?extdetail=M3U http://filext.com/detaillist.php?extdetail=MP3 http://filext.com/detaillist.php?extdetail=OGG http://filext.com/detaillist.php?extdetail=FLAC http://filext.com/detaillist.php?extdetail=MP4
Definition at line 65 of file playlist.c.
Referenced by file_make_cache_entry(), list_songs(), and send_rss().
|
static |
Function pointers array.
Of course, as we defined function pointers, we will use them in a nice array. They will be called in a sequential manner.
make_cache_entry() MUST be called first.
Note : a make_dir_entry() function to handle directories has already been tried, unfortunately, it implies some bad side effects. Plus, it probably does not make things any quicker and increases the number of function calls. (that's a personnal NB to the developpers, to avoid repeating twice the same havoc as time goes by ;o)
Functions are ordered in what we believe is a top-down order of most frequent filetypes.
Definition at line 131 of file playlist.c.
Referenced by make_music_entry().