Blame include/cdio/udf.h

Packit dd8086
/*  
Packit dd8086
    Copyright (C) 2005, 2006, 2008, 2010 Rocky Bernstein <rocky@gnu.org>
Packit dd8086
Packit dd8086
    This program is free software: you can redistribute it and/or modify
Packit dd8086
    it under the terms of the GNU General Public License as published by
Packit dd8086
    the Free Software Foundation, either version 3 of the License, or
Packit dd8086
    (at your option) any later version.
Packit dd8086
Packit dd8086
    This program is distributed in the hope that it will be useful,
Packit dd8086
    but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit dd8086
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit dd8086
    GNU General Public License for more details.
Packit dd8086
Packit dd8086
    You should have received a copy of the GNU General Public License
Packit dd8086
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
Packit dd8086
*/
Packit dd8086
Packit dd8086
/*!
Packit dd8086
 * \file udf.h 
Packit dd8086
 *
Packit dd8086
 * \brief The top-level interface header for libudf: UDF filesystem
Packit dd8086
 * library; applications include this.
Packit dd8086
 *
Packit dd8086
*/
Packit dd8086
Packit dd8086
#ifndef UDF_H
Packit dd8086
#define UDF_H 
Packit dd8086
Packit dd8086
#include <cdio/cdio.h>
Packit dd8086
#include <cdio/ecma_167.h>
Packit dd8086
#include <cdio/posix.h>
Packit dd8086
Packit dd8086
typedef uint16_t partition_num_t;
Packit dd8086
Packit dd8086
/** Opaque structures. */
Packit dd8086
typedef struct udf_s udf_t; 
Packit dd8086
typedef struct udf_file_s udf_file_t;
Packit dd8086
Packit dd8086
typedef struct udf_dirent_s {
Packit dd8086
    char              *psz_name;
Packit dd8086
    bool               b_dir;    /* true if this entry is a directory. */
Packit dd8086
    bool               b_parent; /* True if has parent directory (e.g. not root
Packit dd8086
                                    directory). If not set b_dir will probably
Packit dd8086
                                    be true. */
Packit dd8086
    udf_t             *p_udf;
Packit dd8086
    uint32_t           i_part_start;
Packit dd8086
    uint32_t           i_loc, i_loc_end;
Packit dd8086
    uint64_t           dir_left;
Packit dd8086
    uint8_t           *sector;
Packit dd8086
    udf_fileid_desc_t *fid;
Packit dd8086
    
Packit dd8086
    /* This field has to come last because it is variable in length. */
Packit dd8086
    udf_file_entry_t   fe;
Packit dd8086
} udf_dirent_t;
Packit dd8086
Packit dd8086
Packit dd8086
Packit dd8086
/**
Packit dd8086
   Imagine the below a \#define'd value rather than distinct values of
Packit dd8086
   an enum.
Packit dd8086
*/
Packit dd8086
typedef enum {
Packit dd8086
  UDF_BLOCKSIZE       = 2048
Packit dd8086
} udf_enum1_t; 
Packit dd8086
Packit dd8086
/** This variable is trickery to force the above enum symbol value to
Packit dd8086
    be recorded in debug symbol tables. It is used to allow one refer
Packit dd8086
    to above enumeration values in a debugger and debugger
Packit dd8086
    expressions */
Packit dd8086
extern udf_enum1_t debug_udf_enum1;
Packit dd8086
Packit dd8086
#ifdef __cplusplus
Packit dd8086
extern "C" {
Packit dd8086
#endif /* __cplusplus */
Packit dd8086
Packit dd8086
  /*!
Packit dd8086
    Close UDF and free resources associated with p_udf.
Packit dd8086
  */
Packit dd8086
  bool udf_close (udf_t *p_udf);
Packit dd8086
  
Packit dd8086
  /*!  
Packit dd8086
    Seek to a position i_start and then read i_blocks. Number of
Packit dd8086
    blocks read is returned. One normally expects the return to be
Packit dd8086
    equal to i_blocks.
Packit dd8086
  */
Packit dd8086
Packit dd8086
  driver_return_code_t udf_read_sectors (const udf_t *p_udf, void *ptr, 
Packit dd8086
                                         lsn_t i_start,  long int i_blocks);
Packit dd8086
Packit dd8086
  /*!
Packit dd8086
    Open an UDF for reading. Maybe in the future we will have
Packit dd8086
    a mode. NULL is returned on error.
Packit dd8086
    
Packit dd8086
    Caller must free result - use udf_close for that.
Packit dd8086
  */
Packit dd8086
  udf_t *udf_open (const char *psz_path);
Packit dd8086
  
Packit dd8086
  /*!
Packit dd8086
    Return the partition number of the the opened udf handle. -1 
Packit dd8086
    Is returned if we have an error.
Packit dd8086
  */
Packit dd8086
  int16_t udf_get_part_number(const udf_t *p_udf);
Packit dd8086
Packit dd8086
  /*!
Packit dd8086
    Get the root in p_udf. If b_any_partition is false then
Packit dd8086
    the root must be in the given partition.
Packit dd8086
    NULL is returned if the partition is not found or a root is not found or
Packit dd8086
    there is on error.
Packit dd8086
Packit dd8086
    Caller must free result - use udf_file_free for that.
Packit dd8086
  */
Packit dd8086
  udf_dirent_t *udf_get_root (udf_t *p_udf, bool b_any_partition, 
Packit dd8086
                              partition_num_t i_partition);
Packit dd8086
  
Packit dd8086
  /**
Packit dd8086
   * Gets the Volume Identifier string, in 8bit unicode (latin-1)
Packit dd8086
   * psz_volid, place to put the string
Packit dd8086
   * i_volid, size of the buffer psz_volid points to
Packit dd8086
   * returns the size of buffer needed for all data
Packit dd8086
   */
Packit dd8086
  int udf_get_volume_id(udf_t *p_udf, /*out*/ char *psz_volid,  
Packit dd8086
                        unsigned int i_volid);
Packit dd8086
  
Packit dd8086
  /**
Packit dd8086
   * Gets the Volume Set Identifier, as a 128-byte dstring (not decoded)
Packit dd8086
   * WARNING This is not a null terminated string
Packit dd8086
   * volsetid, place to put the data
Packit dd8086
   * i_volsetid, size of the buffer psz_volsetid points to 
Packit dd8086
   * the buffer should be >=128 bytes to store the whole volumesetidentifier
Packit dd8086
   * returns the size of the available volsetid information (128)
Packit dd8086
   * or 0 on error
Packit dd8086
   */
Packit dd8086
  int udf_get_volumeset_id(udf_t *p_udf, /*out*/ uint8_t *volsetid,
Packit dd8086
                           unsigned int i_volsetid);
Packit dd8086
Packit dd8086
  /**
Packit dd8086
   * Gets the Logical Volume Identifier string, in 8bit unicode (latin-1)
Packit dd8086
   * psz_logvolid, place to put the string
Packit dd8086
   * i_logvolid, size of the buffer psz_logvolid points to
Packit dd8086
   * returns the size of buffer needed for all data
Packit dd8086
   * A call to udf_get_root() should have been issued before this call
Packit dd8086
   */
Packit dd8086
  int udf_get_logical_volume_id(udf_t *p_udf, /*out*/ char *psz_logvolid,  
Packit dd8086
                        unsigned int i_logvolid);
Packit dd8086
Packit dd8086
  /*!
Packit dd8086
    Return a file pointer matching psz_name. 
Packit dd8086
  */
Packit dd8086
  udf_dirent_t *udf_fopen(udf_dirent_t *p_udf_root, const char *psz_name);
Packit dd8086
  
Packit dd8086
  /*! udf_mode_string - fill in string PSZ_STR with an ls-style ASCII
Packit dd8086
    representation of the i_mode. PSZ_STR is returned.
Packit dd8086
Packit dd8086
    10 characters are stored in PSZ_STR; a terminating null byte is added.
Packit dd8086
    The characters stored in PSZ_STR are:
Packit dd8086
    
Packit dd8086
    0   File type.  'd' for directory, 'c' for character
Packit dd8086
        special, 'b' for block special, 'm' for multiplex,
Packit dd8086
        'l' for symbolic link, 's' for socket, 'p' for fifo,
Packit dd8086
        '-' for regular, '?' for any other file type
Packit dd8086
Packit dd8086
    1   'r' if the owner may read, '-' otherwise.
Packit dd8086
Packit dd8086
    2   'w' if the owner may write, '-' otherwise.
Packit dd8086
Packit dd8086
    3   'x' if the owner may execute, 's' if the file is
Packit dd8086
        set-user-id, '-' otherwise.
Packit dd8086
        'S' if the file is set-user-id, but the execute
Packit dd8086
        bit isn't set.
Packit dd8086
Packit dd8086
    4   'r' if group members may read, '-' otherwise.
Packit dd8086
Packit dd8086
    5   'w' if group members may write, '-' otherwise.
Packit dd8086
Packit dd8086
    6   'x' if group members may execute, 's' if the file is
Packit dd8086
        set-group-id, '-' otherwise.
Packit dd8086
        'S' if it is set-group-id but not executable.
Packit dd8086
Packit dd8086
    7   'r' if any user may read, '-' otherwise.
Packit dd8086
Packit dd8086
    8   'w' if any user may write, '-' otherwise.
Packit dd8086
Packit dd8086
    9   'x' if any user may execute, 't' if the file is "sticky"
Packit dd8086
        (will be retained in swap space after execution), '-'
Packit dd8086
        otherwise.
Packit dd8086
        'T' if the file is sticky but not executable.  */
Packit dd8086
Packit dd8086
    char *udf_mode_string (mode_t i_mode, char *psz_str);
Packit dd8086
Packit dd8086
    bool udf_get_lba(const udf_file_entry_t *p_udf_fe, 
Packit dd8086
                     /*out*/ uint32_t *start, /*out*/ uint32_t *end);
Packit dd8086
Packit dd8086
#ifdef __cplusplus
Packit dd8086
}
Packit dd8086
#endif /* __cplusplus */
Packit dd8086
Packit dd8086
#include <cdio/udf_time.h>
Packit dd8086
#include <cdio/udf_file.h>
Packit dd8086
Packit dd8086
#endif /*UDF_H*/