Main Page | Data Structures | File List | Data Fields | Globals | Related Pages

cache.h File Reference

#include "mod_musicindex.h"
#include <string.h>
#include <dirent.h>
#include <errno.h>
#include <stdio.h>
#include <sys/file.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>

Go to the source code of this file.

Data Structures

struct  mu_cache_data
 Structure used to exchange data between cache management routines. More...


Defines

#define CA_FATAL   10
 Something bad happened.

#define CA_MISSARG   20
 Argument missing.

#define CA_CREATE   30
 Requesting file creation.

#define CA_LOCKED   40
 Cache entry is locked and unusuable.


Functions

short cache_check_dir (request_rec *, mu_config *, mu_cache_data *)
 Checks if a directory already exists in the cache.

short cache_check_file (request_rec *, mu_config *, mu_cache_data *)
 Checks if a file already exists in the cache.

mu_entcache_read_file (request_rec *, mu_ent *, mu_config *, mu_cache_data *)
 Reads cache file information and fills mu_ent entry accordingly.

short cache_write_file (request_rec *, mu_ent *, mu_config *, mu_cache_data *)
 Creates and writes cache file information.


Define Documentation

#define CA_CREATE   30
 

Requesting file creation.

Definition at line 48 of file cache.h.

Referenced by cache_check_file(), and make_music_entry().

#define CA_FATAL   10
 

Something bad happened.

Definition at line 46 of file cache.h.

Referenced by cache_check_dir(), cache_check_file(), cache_init(), cache_make_dir(), and cache_write_file().

#define CA_LOCKED   40
 

Cache entry is locked and unusuable.

Definition at line 49 of file cache.h.

Referenced by cache_write_file().

#define CA_MISSARG   20
 

Argument missing.

Definition at line 47 of file cache.h.

Referenced by cache_check_dir(), and cache_check_file().


Function Documentation

short cache_check_dir request_rec *  r,
mu_config conf,
mu_cache_data cachedata
 

Checks if a directory already exists in the cache.

This function is called when the caller wants to know whether a given directory (as found in the cachedata struct) exists or not in the cache. If the directory exists, the function returns successfully, otherwise it tries to create it if possible and returns accordingly.

Parameters:
r Apache request_rec struct to handle log writings.
conf The config structure used to find out cache configuration.
cachedata A structure in which the full directory path can be found.
Returns:
0 on succes, CA_MISSARG if cachedata->name is missing, CA_FATAL otherwise.

Definition at line 285 of file cache.c.

References CA_FATAL, CA_MISSARG, cache_init(), cache_make_dir(), mu_config::cache_path, cache_remove_dir(), error_handler(), and mu_cache_data::name.

Referenced by make_music_entry().

short cache_check_file request_rec *  r,
mu_config conf,
mu_cache_data cachedata
 

Checks if a file already exists in the cache.

This function is called when the caller wants to know whether a given file (as found in the cachedata struct) exists or not in the cache. If the file exists, the function returns successfully, providing the FILE stream in cachedata->stream, otherwise it returns a specific error code.

Parameters:
r Apache request_rec struct to handle log writings.
conf The config structure used to find out cache configuration.
cachedata A structure in which the full file path can be found and in which the file stream will be set if needed.
Returns:
0 on succes, CA_CREATE if the file doesn't exist but can be created, CA_MISSARG if cachedata->name is missing, CA_FATAL otherwise.

Definition at line 346 of file cache.c.

References CA_CREATE, CA_FATAL, CA_MISSARG, cache_init(), mu_config::cache_path, error_handler(), mu_cache_data::name, and mu_cache_data::stream.

Referenced by make_music_entry().

mu_ent* cache_read_file request_rec *  r,
mu_ent head,
mu_config conf,
mu_cache_data cachedata
 

Reads cache file information and fills mu_ent entry accordingly.

This function instanciates a new mu_ent entry and fills in its fields with data gathered from the cache file.

Bug:
Consummes 3*1k of RAM for each file read; we could probably shorten that to 3*256B, but the fields can be up to 1k long according to id3.org
Parameters:
r Apache request_rec struct to handle log writings.
conf The config structure used to find out cache configuration.
head The current mu_ent pointer.
cachedata A structure in which the cache file stream can be found.
Returns:
A new mu_ent entry, or head if failure.

Definition at line 396 of file cache.c.

References mu_ent::album, mu_ent::artist, mu_ent::bitrate, mu_ent::date, mu_ent::filetype, mu_ent::genre, mu_ent::length, MAX_STRING, new_ent(), mu_ent::posn, mu_ent::size, mu_cache_data::stream, mu_ent::title, and mu_ent::track.

Referenced by make_music_entry().

short cache_write_file request_rec *  r,
mu_ent p,
mu_config conf,
mu_cache_data cachedata
 

Creates and writes cache file information.

This function creates a new cache file (using cachedata->name), and fills it with the data contained in the mu_ent p structure.

Parameters:
r Apache request_rec struct to handle log writings.
conf The config structure used to find out cache configuration.
p A mu_ent struct containing the data to store.
cachedata A structure in which the cache file name can be found.
Returns:
0 on success, CA_LOCKED if the file is locked already, CA_FATAL otherwise.

Definition at line 450 of file cache.c.

References mu_ent::album, mu_ent::artist, mu_ent::bitrate, CA_FATAL, CA_LOCKED, mu_config::cache_path, mu_ent::date, error_handler(), mu_ent::filetype, mu_ent::genre, mu_ent::length, mu_cache_data::name, mu_ent::posn, mu_ent::size, mu_cache_data::stream, mu_ent::title, and mu_ent::track.

Referenced by make_music_entry().


Generated on Thu Oct 30 13:50:29 2003 for mod_musicindex by doxygen 1.3.4