rsc_files.h 4.58 KB
Newer Older
1
/*****************************************************************************
Michel Kaempf's avatar
Michel Kaempf committed
2
 * rsc_files.h: resources files manipulation functions
3
 * This library describes a general format used to store 'resources'. Resources
Michel Kaempf's avatar
Michel Kaempf committed
4
 * can be anything, including pictures, audio streams, and so on.
5
 *****************************************************************************
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
 * Copyright (C) 1999, 2000 VideoLAN
 *
 * Authors:
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with this program; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 *****************************************************************************/

/*****************************************************************************
Michel Kaempf's avatar
Michel Kaempf committed
27 28
 * Requires:
 *  config.h
29 30
 *  common.h
 *****************************************************************************/
Michel Kaempf's avatar
Michel Kaempf committed
31

32
/*****************************************************************************
Michel Kaempf's avatar
Michel Kaempf committed
33
 * Constants
34
 *****************************************************************************/
Michel Kaempf's avatar
Michel Kaempf committed
35

36
/* Maximum length of a resource name (not including the final '\0') - this
Michel Kaempf's avatar
Michel Kaempf committed
37 38 39
 * constant should not be changed without extreme care */
#define RESOURCE_MAX_NAME   32

40
/*****************************************************************************
Michel Kaempf's avatar
Michel Kaempf committed
41
 * resource_descriptor_t: resource descriptor
42
 *****************************************************************************
Michel Kaempf's avatar
Michel Kaempf committed
43
 * This type describe an entry in the resource table.
44
 *****************************************************************************/
Michel Kaempf's avatar
Michel Kaempf committed
45 46
typedef struct
{
47 48 49 50
    char    psz_name[RESOURCE_MAX_NAME + 1];                         /* name */
    u16     i_type;                                                  /* type */
    u64     i_offset;                                         /* data offset */
    u64     i_size;                                             /* data size */
Michel Kaempf's avatar
Michel Kaempf committed
51 52 53
} resource_descriptor_t;

/* Resources types */
54 55
#define EMPTY_RESOURCE      0                        /* empty place in table */
#define PICTURE_RESOURCE    10                       /* native video picture */
Michel Kaempf's avatar
Michel Kaempf committed
56

57
/*****************************************************************************
Michel Kaempf's avatar
Michel Kaempf committed
58
 * resource_file_t: resource file descriptor
59
 *****************************************************************************
Michel Kaempf's avatar
Michel Kaempf committed
60 61
 * This type describes a resource file and store it's resources table. It can
 * be used through the *Resource functions, or directly with the i_file field.
62
 *****************************************************************************/
Michel Kaempf's avatar
Michel Kaempf committed
63 64 65
typedef struct
{
    /* File informations */
66 67 68 69
    int                     i_file;                       /* file descriptor */
    int                     i_type;                             /* file type */
    boolean_t               b_up_to_date;            /* is file up to date ? */
    boolean_t               b_read_only;                   /* read-only mode */
Michel Kaempf's avatar
Michel Kaempf committed
70 71

    /* Resources table */
72 73
    int                     i_size;                            /* table size */
    resource_descriptor_t * p_resource;                   /* resources table */
Michel Kaempf's avatar
Michel Kaempf committed
74 75 76
} resource_file_t;

/* Resources files types */
77
#define VLC_RESOURCE_FILE   0               /* VideoLAN Client resource file */
Michel Kaempf's avatar
Michel Kaempf committed
78

79
/*****************************************************************************
Michel Kaempf's avatar
Michel Kaempf committed
80
 * Prototypes
81
 *****************************************************************************/
Michel Kaempf's avatar
Michel Kaempf committed
82 83 84 85 86 87 88 89
resource_file_t *   CreateResourceFile  ( char *psz_filename, int i_type, int i_size, int i_mode );
resource_file_t *   OpenResourceFile    ( char *psz_filename, int i_type, int i_flags );
int                 UpdateResourceFile  ( resource_file_t *p_file );
int                 CloseResourceFile   ( resource_file_t *p_file );

int                 SeekResource        ( resource_file_t *p_file, char *psz_name, int i_type );
int                 ReadResource        ( resource_file_t *p_file, char *psz_name, int i_type,
                                          size_t max_size, byte_t *p_data );
90
int                 WriteResource       ( resource_file_t *p_file, char *psz_name, int i_type,
Michel Kaempf's avatar
Michel Kaempf committed
91 92
                                          size_t size, byte_t *p_data );