zipstream.c File Reference

Include dependency graph for zipstream.c:


Data Structures

struct  stream_sys_t
 ************************************************************************** Struct definitions More...
struct  item
struct  node

Defines

#define FILENAME_TEXT   N_( "Media in Zip" )
 ************************************************************************** Preamble
#define FILENAME_LONGTEXT   N_( "Path to the media in the Zip archive" )

Typedefs

typedef struct node node
typedef struct item item

Functions

int vlc_entry__main (module_t *p_module)
 ************************************************************************** Module descriptor
const char * vlc_entry_license__main (void)
static int Read (stream_t *, void *p_read, unsigned int i_read)
 ************************************************************************* Local prototypes
static int Peek (stream_t *s, const uint8_t **pp_peek, unsigned int i_peek)
 ************************************************************************* Peek
static int Control (stream_t *s, int i_query, va_list args)
 ************************************************************************* Control
static int Fill (stream_t *)
static int CreatePlaylist (stream_t *s, char **pp_buffer)
static int GetFilesInZip (stream_t *p_this, unzFile file, vlc_array_t *p_filenames, vlc_array_t *p_fileinfos)
 ************************************************************************** Zip utility functions
static nodefindOrCreateParentNode (node *root, const char *fullpath)
 **************************************************************************
static int WriteXSPF (char **pp_buffer, vlc_array_t *p_filenames, const char *psz_zippath)
 **************************************************************************
static int nodeToXSPF (char **pp_buffer, node *n, bool b_root)
 **************************************************************************
static nodenew_node (char *name)
 ************************************************************************** Some helpers
static itemnew_item (int id)
static void free_all_node (node *root)
static int astrcatf (char **ppsz_dest, const char *psz_fmt_src,...)
int StreamOpen (vlc_object_t *p_this)
 ************************************************************************** Open
void StreamClose (vlc_object_t *p_this)
 ************************************************************************* Close
bool isAllowedChar (char c)
 ************************************************************************** XSPF generation functions
static int escapeToXml (char **ppsz_encoded, const char *psz_url)
 **************************************************************************
static void ZCALLBACK * ZipIO_Open (void *opaque, const char *file, int mode)
 ************************************************************************** ZipIO function definitions : how to use vlc_stream to read the zip
static unsigned long ZCALLBACK ZipIO_Read (void *opaque, void *stream, void *buf, unsigned long size)
 **************************************************************************
static long ZCALLBACK ZipIO_Tell (void *opaque, void *stream)
 **************************************************************************
static long ZCALLBACK ZipIO_Seek (void *opaque, void *stream, unsigned long offset, int origin)
 **************************************************************************
static int ZCALLBACK ZipIO_Close (void *opaque, void *stream)
 **************************************************************************
static uLong ZCALLBACK ZipIO_Write (void *opaque, void *stream, const void *buf, uLong size)
 **************************************************************************
static int ZCALLBACK ZipIO_Error (void *opaque, void *stream)
 **************************************************************************

Variables

static const uint8_t p_zip_marker [] = { 0x50, 0x4b, 0x03, 0x04 }
 ************************************************************************** Zip file identifier
static const int i_zip_marker = 4

Define Documentation

#define FILENAME_LONGTEXT   N_( "Path to the media in the Zip archive" )

#define FILENAME_TEXT   N_( "Media in Zip" )

************************************************************************** Preamble


Typedef Documentation

typedef struct item item

typedef struct node node


Function Documentation

static int astrcatf ( char **  ppsz_dest,
const char *  psz_fmt_src,
  ... 
) [static]

References vasprintf().

Referenced by nodeToXSPF(), and WriteXSPF().

static int Control ( stream_t s,
int  i_query,
va_list  args 
) [static]

static int CreatePlaylist ( stream_t s,
char **  pp_buffer 
) [static]

static int escapeToXml ( char **  ppsz_encoded,
const char *  psz_url 
) [static]

**************************************************************************

Escape string to be XML valid Allowed chars are defined by the above function isAllowedChar() Invalid chars are escaped using non standard '?XX' notation. NOTE: We cannot trust VLC internal Web encoding functions because they are not able to encode and decode some rare utf-8 characters properly. Also, we don't control exactly when they are called (from this module).

References isAllowedChar(), VLC_ENOMEM, and VLC_SUCCESS.

Referenced by WriteXSPF().

static int Fill ( stream_t s  )  [static]

static node * findOrCreateParentNode ( node root,
const char *  fullpath 
) [static]

**************************************************************************

Either create or find the parent node of the item

References node::child, node::name, new_node(), node::next, and strdup().

Referenced by WriteXSPF().

static void free_all_node ( node root  )  [inline, static]

References node::child, node::name, and node::next.

Referenced by WriteXSPF().

static int GetFilesInZip ( stream_t p_this,
unzFile  file,
vlc_array_t p_filenames,
vlc_array_t p_fileinfos 
) [static]

************************************************************************** Zip utility functions

************************************************************************** List files in zip and append their names to p_array

Parameters:
p_this 
file Opened zip file
p_array vlc_array_t which will receive all filenames
In case of error, returns VLC_EGENERIC. In case of success, returns number of files found, and goes back to first file.

References i, msg_Warn, strdup(), vlc_array_append(), VLC_EGENERIC, VLC_ENOMEM, and ZIP_FILENAME_LEN.

Referenced by CreatePlaylist().

bool isAllowedChar ( char  c  ) 

************************************************************************** XSPF generation functions

Common function.

************************************************************************** Check a character for allowance in the Xml. Allowed chars are: a-z, A-Z, 0-9, \, /, ., ' ', _ and :

Referenced by escapeToXml(), and unescapeXml().

static item* new_item ( int  id  )  [inline, static]

References item::id.

Referenced by WriteXSPF().

static node* new_node ( char *  name  )  [inline, static]

************************************************************************** Some helpers

References convert_xml_special_chars(), and node::name.

Referenced by findOrCreateParentNode(), and WriteXSPF().

static int nodeToXSPF ( char **  pp_buffer,
node n,
bool  b_root 
) [static]

**************************************************************************

Recursively convert a node to its XSPF representation

References astrcatf(), node::child, i, item::id, node::media, node::name, item::next, and VLC_SUCCESS.

Referenced by WriteXSPF().

static int Peek ( stream_t s,
const uint8_t **  pp_peek,
unsigned int  i_peek 
) [static]

************************************************************************* Peek

References __MIN, Fill(), stream_sys_t::i_len, stream_sys_t::i_pos, stream_t::p_sys, p_sys, and stream_sys_t::psz_xspf.

static int Read ( stream_t s,
void *  p_read,
unsigned int  i_read 
) [static]

************************************************************************* Local prototypes

************************************************************************* Stream filters functions

************************************************************************* Read

References __MIN, Fill(), stream_sys_t::i_len, stream_sys_t::i_pos, stream_t::p_sys, p_sys, and stream_sys_t::psz_xspf.

void StreamClose ( vlc_object_t p_this  ) 

************************************************************************* Close

References stream_sys_t::fileFunctions, stream_t::p_sys, p_sys, stream_sys_t::psz_path, stream_sys_t::psz_xspf, and stream_sys_t::zipFile.

Referenced by Demux(), and SessionsSetup().

int StreamOpen ( vlc_object_t p_this  ) 

************************************************************************** Open

************************************************************************** Module access points: stream_filter

References asprintf(), Control(), stream_sys_t::fileFunctions, i_zip_marker, msg_Warn, stream_t::p_source, stream_t::p_sys, p_sys, p_zip_marker, Peek(), stream_t::pf_control, stream_t::pf_peek, stream_t::pf_read, stream_sys_t::psz_path, stream_t::psz_path, Read(), stream_Peek(), VLC_EGENERIC, VLC_ENOMEM, VLC_SUCCESS, stream_sys_t::zipFile, ZipIO_Close(), ZipIO_Error(), ZipIO_Open(), ZipIO_Read(), ZipIO_Seek(), ZipIO_Tell(), and ZipIO_Write().

int vlc_entry__main ( module_t p_module  ) 

************************************************************************** Module descriptor

const char* vlc_entry_license__main ( void   ) 

static int WriteXSPF ( char **  pp_buffer,
vlc_array_t p_filenames,
const char *  psz_zippath 
) [static]

**************************************************************************

Write the XSPF playlist given the list of files

References asprintf(), astrcatf(), convert_xml_special_chars(), DIR_SEP_CHAR, escapeToXml(), findOrCreateParentNode(), free_all_node(), i, node::media, new_item(), new_node(), item::next, nodeToXSPF(), psz_name, strdup(), vlc_array_count(), vlc_array_item_at_index(), VLC_SUCCESS, and ZIP_SEP.

Referenced by CreatePlaylist().

static int ZCALLBACK ZipIO_Close ( void *  opaque,
void *  stream 
) [static]

**************************************************************************

close the stream

Parameters:
opaque should be the stream
stream stream created by ZipIO_Open
Returns:
always VLC_SUCCESS This closes zip archive

References VLC_SUCCESS.

static int ZCALLBACK ZipIO_Error ( void *  opaque,
void *  stream 
) [static]

**************************************************************************

I/O functions for the ioapi: test error (man 3 ferror)

static void ZCALLBACK* ZipIO_Open ( void *  opaque,
const char *  file,
int  mode 
) [static]

************************************************************************** ZipIO function definitions : how to use vlc_stream to read the zip

************************************************************************** interface for unzip module to open a file using a vlc_stream

Parameters:
opaque 
filename 
mode how to open the file (read/write ?). We support only read
Returns:
opaque

References msg_Dbg.

static unsigned long ZCALLBACK ZipIO_Read ( void *  opaque,
void *  stream,
void *  buf,
unsigned long  size 
) [static]

**************************************************************************

read something from stream into buffer

Parameters:
opaque should be the stream
stream stream created by ZipIO_Open
buf buffer to read the file
size length of this buffer
Returns:
return the number of bytes read (<= size)

References stream_t::p_source, and stream_Read().

static long ZCALLBACK ZipIO_Seek ( void *  opaque,
void *  stream,
unsigned long  offset,
int  origin 
) [static]

**************************************************************************

seek in the stream

Parameters:
opaque should be the stream
stream stream created by ZipIO_Open
offset positive offset to seek
origin current position in stream
Returns:
¿ VLC_SUCCESS or an error code ?

References long(), stream_t::p_source, and stream_Seek().

static long ZCALLBACK ZipIO_Tell ( void *  opaque,
void *  stream 
) [static]

**************************************************************************

tell size of stream

Parameters:
opaque should be the stream
stream stream created by ZipIO_Open
Returns:
size of the file / stream ATTENTION: this is not stream_Tell, but stream_Size !

References stream_t::p_source, and stream_Size().

static uLong ZCALLBACK ZipIO_Write ( void *  opaque,
void *  stream,
const void *  buf,
uLong  size 
) [static]

**************************************************************************

I/O functions for the ioapi: write (assert insteadof segfault)


Variable Documentation

const int i_zip_marker = 4 [static]

Referenced by StreamOpen().

const uint8_t p_zip_marker[] = { 0x50, 0x4b, 0x03, 0x04 } [static]

************************************************************************** Zip file identifier

Referenced by StreamOpen().


Generated on Tue May 25 08:05:09 2010 for VLC by  doxygen 1.5.6