mod_musicindex  1.4.1
output-tarball.c File Reference

Tarballs generation. More...

#include "mod_musicindex.h"
#include <http_core.h>
#include <archive.h>
#include <archive_entry.h>
#include <stdio.h>

Go to the source code of this file.

Data Structures

struct  cdata
 Holds our client data for libarchive. More...

Macros

#define _FILE_OFFSET_BITS   64
#define OT_SEND_DATA   0
 trigger data sending in tarball_op()
#define OT_SEND_SIZE   1
 trigger size report in tarball_op()
#define RWBUFSIZE   8192
 Size of our r/w buffer.
#define QSKIP_CHECKS(q)   (!(q->flags & EF_ALLOWTARBALL))
 Skip file if ...

Functions

static int wrapopen (struct archive *a, void *client_data)
static ssize_t wrapwrite (struct archive *a, void *client_data, const void *buff, size_t n)
static ssize_t wrapwritesize (struct archive *a, void *client_data, const void *buff, size_t n)
static ssize_t tarball_op (request_rec *r, const mu_pack *const pack, int op)
 Triggers tarball operation.
void send_tarball (request_rec *r, const mu_pack *const pack)
 Sends tarball.
ssize_t tarball_size (request_rec *r, const mu_pack *const pack)
 Compute tarball size.

Detailed Description

Tarballs generation.

Author
Thibaut Varene
Version
Revision:
1023
Date
2006-2008
2012-2013

This file handles on the fly tarball generation and associated operations

Todo:
maybe use apr_file I/O?

Definition in file output-tarball.c.

Macro Definition Documentation

#define _FILE_OFFSET_BITS   64

Definition at line 32 of file output-tarball.c.

#define OT_SEND_DATA   0

trigger data sending in tarball_op()

Definition at line 51 of file output-tarball.c.

Referenced by send_tarball(), and tarball_op().

#define OT_SEND_SIZE   1

trigger size report in tarball_op()

Definition at line 52 of file output-tarball.c.

Referenced by tarball_size().

#define QSKIP_CHECKS (   q)    (!(q->flags & EF_ALLOWTARBALL))

Skip file if ...

Definition at line 56 of file output-tarball.c.

Referenced by tarball_op().

#define RWBUFSIZE   8192

Size of our r/w buffer.

Definition at line 54 of file output-tarball.c.

Referenced by tarball_op().

Function Documentation

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

Sends tarball.

Parameters
rApache request_rec struct to handle connection details.
packA pack of music entries.

Definition at line 176 of file output-tarball.c.

References OT_SEND_DATA, and tarball_op().

Referenced by handle_musicindex().

static ssize_t tarball_op ( request_rec *  r,
const mu_pack *const  pack,
int  op 
)
static

Triggers tarball operation.

Parameters
rApache request_rec struct to handle connection details.
packA pack of music entries.
opType of operation requested.
Returns
the size of the tarball that send_tarball() would generate for the given set of files. Only valid with #op == OT_SEND_SIZE.

It is a known "feature" that when tar'ing a custom playlist, the generated tarball will contain the full path as published on the webserver, including '/'. We could get rid of the leading '/' if needed, but there's one good reason not to put all the files at the root of one big tarball: in case there are name doublons.

Definition at line 101 of file output-tarball.c.

References mu_pack::fhead, mu_ent::file, mu_ent::filename, likely, mu_ent::next, OT_SEND_DATA, QSKIP_CHECKS, cdata::r, RWBUFSIZE, mu_ent::size, unlikely, wrapopen(), wrapwrite(), and wrapwritesize().

Referenced by send_tarball(), and tarball_size().

ssize_t tarball_size ( request_rec *  r,
const mu_pack *const  pack 
)

Compute tarball size.

Parameters
rApache request_rec struct to handle connection details.
packA pack of music entries.
Returns
the size of the tarball that send_tarball() would generate for the given set of files.

Definition at line 190 of file output-tarball.c.

References OT_SEND_SIZE, and tarball_op().

Referenced by handle_musicindex().

static int wrapopen ( struct archive *  a,
void *  client_data 
)
static

Definition at line 65 of file output-tarball.c.

Referenced by tarball_op().

static ssize_t wrapwrite ( struct archive *  a,
void *  client_data,
const void *  buff,
size_t  n 
)
static

Definition at line 71 of file output-tarball.c.

References cdata::r.

Referenced by tarball_op().

static ssize_t wrapwritesize ( struct archive *  a,
void *  client_data,
const void *  buff,
size_t  n 
)
static

Definition at line 79 of file output-tarball.c.

Referenced by tarball_op().