libisofs 1.1.6
libisofs-1.1.6/libisofs/libisofs.h
Go to the documentation of this file.
00001 
00002 #ifndef LIBISO_LIBISOFS_H_
00003 #define LIBISO_LIBISOFS_H_
00004 
00005 /*
00006  * Copyright (c) 2007-2008 Vreixo Formoso, Mario Danic
00007  * Copyright (c) 2009-2011 Thomas Schmitt
00008  *
00009  * This file is part of the libisofs project; you can redistribute it and/or
00010  * modify it under the terms of the GNU General Public License version 2 
00011  * or later as published by the Free Software Foundation. 
00012  * See COPYING file for details.
00013  */
00014 
00015 /* Important: If you add a public API function then add its name to file
00016                  libisofs/libisofs.ver 
00017 */
00018 
00019 /* 
00020  *
00021  * Applications must use 64 bit off_t.
00022  * E.g. on 32-bit GNU/Linux by defining
00023  *   #define _LARGEFILE_SOURCE
00024  *   #define _FILE_OFFSET_BITS 64
00025  * The minimum requirement is to interface with the library by 64 bit signed
00026  * integers where libisofs.h or libisoburn.h prescribe off_t.
00027  * Failure to do so may result in surprising malfunction or memory faults.
00028  * 
00029  * Application files which include libisofs/libisofs.h must provide
00030  * definitions for uint32_t and uint8_t.
00031  * This can be achieved either:
00032  * - by using autotools which will define HAVE_STDINT_H or HAVE_INTTYPES_H
00033  *   according to its ./configure tests,
00034  * - or by defining the macros HAVE_STDINT_H resp. HAVE_INTTYPES_H according
00035  *   to the local situation,
00036  * - or by appropriately defining uint32_t and uint8_t by other means,
00037  *   e.g. by including inttypes.h before including libisofs.h
00038  */
00039 #ifdef HAVE_STDINT_H
00040 #include <stdint.h>
00041 #else
00042 #ifdef HAVE_INTTYPES_H
00043 #include <inttypes.h>
00044 #endif
00045 #endif
00046 
00047 
00048 /*
00049  * Normally this API is operated via public functions and opaque object
00050  * handles. But it also exposes several C structures which may be used to
00051  * provide custom functionality for the objects of the API. The same
00052  * structures are used for internal objects of libisofs, too.
00053  * You are not supposed to manipulate the entrails of such objects if they
00054  * are not your own custom extensions.
00055  *
00056  * See for an example IsoStream = struct iso_stream below.
00057  */
00058 
00059 
00060 #include <sys/stat.h>
00061 
00062 #include <stdlib.h>
00063 
00064 
00065 /**
00066  * The following two functions and three macros are utilities to help ensuring
00067  * version match of application, compile time header, and runtime library.
00068  */
00069 /**
00070  * These three release version numbers tell the revision of this header file
00071  * and of the API it describes. They are memorized by applications at
00072  * compile time.
00073  * They must show the same values as these symbols in ./configure.ac
00074  *     LIBISOFS_MAJOR_VERSION=...
00075  *     LIBISOFS_MINOR_VERSION=...
00076  *     LIBISOFS_MICRO_VERSION=...
00077  * Note to anybody who does own work inside libisofs:
00078  * Any change of configure.ac or libisofs.h has to keep up this equality !
00079  *
00080  * Before usage of these macros on your code, please read the usage discussion
00081  * below.
00082  *
00083  * @since 0.6.2
00084  */
00085 #define iso_lib_header_version_major  1
00086 #define iso_lib_header_version_minor  1
00087 #define iso_lib_header_version_micro  6
00088 
00089 /**
00090  * Get version of the libisofs library at runtime.
00091  * NOTE: This function may be called before iso_init().
00092  *
00093  * @since 0.6.2
00094  */
00095 void iso_lib_version(int *major, int *minor, int *micro);
00096 
00097 /**
00098  * Check at runtime if the library is ABI compatible with the given version.
00099  * NOTE: This function may be called before iso_init().
00100  *
00101  * @return
00102  *      1 lib is compatible, 0 is not.
00103  *
00104  * @since 0.6.2
00105  */
00106 int iso_lib_is_compatible(int major, int minor, int micro);
00107 
00108 /**
00109  * Usage discussion:
00110  *
00111  * Some developers of the libburnia project have differing opinions how to
00112  * ensure the compatibility of libaries and applications.
00113  *
00114  * It is about whether to use at compile time and at runtime the version
00115  * numbers provided here. Thomas Schmitt advises to use them. Vreixo Formoso
00116  * advises to use other means.
00117  *
00118  * At compile time:
00119  *
00120  * Vreixo Formoso advises to leave proper version matching to properly
00121  * programmed checks in the the application's build system, which will
00122  * eventually refuse compilation.
00123  *
00124  * Thomas Schmitt advises to use the macros defined here for comparison with
00125  * the application's requirements of library revisions and to eventually
00126  * break compilation.
00127  *
00128  * Both advises are combinable. I.e. be master of your build system and have
00129  * #if checks in the source code of your application, nevertheless.
00130  *
00131  * At runtime (via iso_lib_is_compatible()):
00132  *
00133  * Vreixo Formoso advises to compare the application's requirements of
00134  * library revisions with the runtime library. This is to allow runtime
00135  * libraries which are young enough for the application but too old for
00136  * the lib*.h files seen at compile time.
00137  *
00138  * Thomas Schmitt advises to compare the header revisions defined here with
00139  * the runtime library. This is to enforce a strictly monotonous chain of
00140  * revisions from app to header to library, at the cost of excluding some older
00141  * libraries.
00142  *
00143  * These two advises are mutually exclusive.
00144  */
00145 
00146 struct burn_source;
00147 
00148 /**
00149  * Context for image creation. It holds the files that will be added to image,
00150  * and several options to control libisofs behavior.
00151  *
00152  * @since 0.6.2
00153  */
00154 typedef struct Iso_Image IsoImage;
00155 
00156 /*
00157  * A node in the iso tree, i.e. a file that will be written to image.
00158  *
00159  * It can represent any kind of files. When needed, you can get the type with
00160  * iso_node_get_type() and cast it to the appropiate subtype. Useful macros
00161  * are provided, see below.
00162  *
00163  * @since 0.6.2
00164  */
00165 typedef struct Iso_Node IsoNode;
00166 
00167 /**
00168  * A directory in the iso tree. It is an special type of IsoNode and can be
00169  * casted to it in any case.
00170  *
00171  * @since 0.6.2
00172  */
00173 typedef struct Iso_Dir IsoDir;
00174 
00175 /**
00176  * A symbolic link in the iso tree. It is an special type of IsoNode and can be
00177  * casted to it in any case.
00178  *
00179  * @since 0.6.2
00180  */
00181 typedef struct Iso_Symlink IsoSymlink;
00182 
00183 /**
00184  * A regular file in the iso tree. It is an special type of IsoNode and can be
00185  * casted to it in any case.
00186  *
00187  * @since 0.6.2
00188  */
00189 typedef struct Iso_File IsoFile;
00190 
00191 /**
00192  * An special file in the iso tree. This is used to represent any POSIX file
00193  * other that regular files, directories or symlinks, i.e.: socket, block and
00194  * character devices, and fifos.
00195  * It is an special type of IsoNode and can be casted to it in any case.
00196  *
00197  * @since 0.6.2
00198  */
00199 typedef struct Iso_Special IsoSpecial;
00200 
00201 /**
00202  * The type of an IsoNode.
00203  *
00204  * When an user gets an IsoNode from an image, (s)he can use
00205  * iso_node_get_type() to get the current type of the node, and then
00206  * cast to the appropriate subtype. For example:
00207  *
00208  * ...
00209  * IsoNode *node;
00210  * res = iso_dir_iter_next(iter, &node);
00211  * if (res == 1 && iso_node_get_type(node) == LIBISO_DIR) {
00212  *      IsoDir *dir = (IsoDir *)node;
00213  *      ...
00214  * }
00215  *
00216  * @since 0.6.2
00217  */
00218 enum IsoNodeType {
00219     LIBISO_DIR,
00220     LIBISO_FILE,
00221     LIBISO_SYMLINK,
00222     LIBISO_SPECIAL,
00223     LIBISO_BOOT
00224 };
00225 
00226 /* macros to check node type */
00227 #define ISO_NODE_IS_DIR(n) (iso_node_get_type(n) == LIBISO_DIR)
00228 #define ISO_NODE_IS_FILE(n) (iso_node_get_type(n) == LIBISO_FILE)
00229 #define ISO_NODE_IS_SYMLINK(n) (iso_node_get_type(n) == LIBISO_SYMLINK)
00230 #define ISO_NODE_IS_SPECIAL(n) (iso_node_get_type(n) == LIBISO_SPECIAL)
00231 #define ISO_NODE_IS_BOOTCAT(n) (iso_node_get_type(n) == LIBISO_BOOT)
00232 
00233 /* macros for safe downcasting */
00234 #define ISO_DIR(n) ((IsoDir*)(ISO_NODE_IS_DIR(n) ? n : NULL))
00235 #define ISO_FILE(n) ((IsoFile*)(ISO_NODE_IS_FILE(n) ? n : NULL))
00236 #define ISO_SYMLINK(n) ((IsoSymlink*)(ISO_NODE_IS_SYMLINK(n) ? n : NULL))
00237 #define ISO_SPECIAL(n) ((IsoSpecial*)(ISO_NODE_IS_SPECIAL(n) ? n : NULL))
00238 
00239 #define ISO_NODE(n) ((IsoNode*)n)
00240 
00241 /**
00242  * File section in an old image.
00243  *
00244  * @since 0.6.8
00245  */
00246 struct iso_file_section
00247 {
00248     uint32_t block;
00249     uint32_t size;
00250 };
00251 
00252 /* If you get here because of a compilation error like
00253 
00254        /usr/include/libisofs/libisofs.h:166: error:
00255        expected specifier-qualifier-list before 'uint32_t'
00256 
00257    then see the paragraph above about the definition of uint32_t.
00258 */
00259 
00260 
00261 /**
00262  * Context for iterate on directory children.
00263  * @see iso_dir_get_children()
00264  *
00265  * @since 0.6.2
00266  */
00267 typedef struct Iso_Dir_Iter IsoDirIter;
00268 
00269 /**
00270  * It represents an El-Torito boot image.
00271  *
00272  * @since 0.6.2
00273  */
00274 typedef struct el_torito_boot_image ElToritoBootImage;
00275 
00276 /**
00277  * An special type of IsoNode that acts as a placeholder for an El-Torito
00278  * boot catalog. Once written, it will appear as a regular file.
00279  *
00280  * @since 0.6.2
00281  */
00282 typedef struct Iso_Boot IsoBoot;
00283 
00284 /**
00285  * Flag used to hide a file in the RR/ISO or Joliet tree.
00286  *
00287  * @see iso_node_set_hidden
00288  * @since 0.6.2
00289  */
00290 enum IsoHideNodeFlag {
00291     /** Hide the node in the ECMA-119 / RR tree */
00292     LIBISO_HIDE_ON_RR = 1 << 0,
00293     /** Hide the node in the Joliet tree, if Joliet extension are enabled */
00294     LIBISO_HIDE_ON_JOLIET = 1 << 1,
00295     /** Hide the node in the ISO-9660:1999 tree, if that format is enabled */
00296     LIBISO_HIDE_ON_1999 = 1 << 2,
00297 
00298     /** With IsoNode and IsoBoot: Write data content even if the node is
00299      *                            not visible in any tree.
00300      *  With directory nodes    : Write data content of IsoNode and IsoBoot
00301      *                            in the directory's tree unless they are
00302      *                            explicitely marked LIBISO_HIDE_ON_RR
00303      *                            without LIBISO_HIDE_BUT_WRITE.
00304      *  @since 0.6.34
00305      */
00306     LIBISO_HIDE_BUT_WRITE = 1 << 3
00307 };
00308 
00309 /**
00310  * El-Torito bootable image type.
00311  *
00312  * @since 0.6.2
00313  */
00314 enum eltorito_boot_media_type {
00315     ELTORITO_FLOPPY_EMUL,
00316     ELTORITO_HARD_DISC_EMUL,
00317     ELTORITO_NO_EMUL
00318 };
00319 
00320 /**
00321  * Replace mode used when addding a node to a file.
00322  * This controls how libisofs will act when you tried to add to a dir a file
00323  * with the same name that an existing file.
00324  *
00325  * @since 0.6.2
00326  */
00327 enum iso_replace_mode {
00328     /**
00329      * Never replace an existing node, and instead fail with
00330      * ISO_NODE_NAME_NOT_UNIQUE.
00331      */
00332     ISO_REPLACE_NEVER,
00333     /**
00334      * Always replace the old node with the new.
00335      */
00336     ISO_REPLACE_ALWAYS,
00337     /**
00338      * Replace with the new node if it is the same file type
00339      */
00340     ISO_REPLACE_IF_SAME_TYPE,
00341     /**
00342      * Replace with the new node if it is the same file type and its ctime
00343      * is newer than the old one.
00344      */
00345     ISO_REPLACE_IF_SAME_TYPE_AND_NEWER,
00346     /**
00347      * Replace with the new node if its ctime is newer than the old one.
00348      */
00349     ISO_REPLACE_IF_NEWER
00350     /*
00351      * TODO #00006 define more values
00352      *  -if both are dirs, add contents (and what to do with conflicts?)
00353      */
00354 };
00355 
00356 /**
00357  * Options for image written.
00358  * @see iso_write_opts_new()
00359  * @since 0.6.2
00360  */
00361 typedef struct iso_write_opts IsoWriteOpts;
00362 
00363 /**
00364  * Options for image reading or import.
00365  * @see iso_read_opts_new()
00366  * @since 0.6.2
00367  */
00368 typedef struct iso_read_opts IsoReadOpts;
00369 
00370 /**
00371  * Source for image reading.
00372  *
00373  * @see struct iso_data_source
00374  * @since 0.6.2
00375  */
00376 typedef struct iso_data_source IsoDataSource;
00377 
00378 /**
00379  * Data source used by libisofs for reading an existing image.
00380  *
00381  * It offers homogeneous read access to arbitrary blocks to different sources
00382  * for images, such as .iso files, CD/DVD drives, etc...
00383  *
00384  * To create a multisession image, libisofs needs a IsoDataSource, that the
00385  * user must provide. The function iso_data_source_new_from_file() constructs
00386  * an IsoDataSource that uses POSIX I/O functions to access data. You can use
00387  * it with regular .iso images, and also with block devices that represent a
00388  * drive.
00389  *
00390  * @since 0.6.2
00391  */
00392 struct iso_data_source
00393 {
00394 
00395     /* reserved for future usage, set to 0 */
00396     int version;
00397 
00398     /**
00399      * Reference count for the data source. Should be 1 when a new source
00400      * is created. Don't access it directly, but with iso_data_source_ref()
00401      * and iso_data_source_unref() functions.
00402      */
00403     unsigned int refcount;
00404 
00405     /**
00406      * Opens the given source. You must open() the source before any attempt
00407      * to read data from it. The open is the right place for grabbing the
00408      * underlying resources.
00409      *
00410      * @return
00411      *      1 if success, < 0 on error (has to be a valid libisofs error code)
00412      */
00413     int (*open)(IsoDataSource *src);
00414 
00415     /**
00416      * Close a given source, freeing all system resources previously grabbed in
00417      * open().
00418      *
00419      * @return
00420      *      1 if success, < 0 on error (has to be a valid libisofs error code)
00421      */
00422     int (*close)(IsoDataSource *src);
00423 
00424     /**
00425      * Read an arbitrary block (2048 bytes) of data from the source.
00426      *
00427      * @param lba
00428      *     Block to be read.
00429      * @param buffer
00430      *     Buffer where the data will be written. It should have at least
00431      *     2048 bytes.
00432      * @return
00433      *      1 if success,
00434      *    < 0 if error. This function has to emit a valid libisofs error code.
00435      *        Predifined (but not mandatory) for this purpose are:
00436      *          ISO_DATA_SOURCE_SORRY ,   ISO_DATA_SOURCE_MISHAP,
00437      *          ISO_DATA_SOURCE_FAILURE , ISO_DATA_SOURCE_FATAL
00438      */
00439     int (*read_block)(IsoDataSource *src, uint32_t lba, uint8_t *buffer);
00440 
00441     /**
00442      * Clean up the source specific data. Never call this directly, it is
00443      * automatically called by iso_data_source_unref() when refcount reach
00444      * 0.
00445      */
00446     void (*free_data)(IsoDataSource *src);
00447 
00448     /** Source specific data */
00449     void *data;
00450 };
00451 
00452 /**
00453  * Return information for image. This is optionally allocated by libisofs,
00454  * as a way to inform user about the features of an existing image, such as
00455  * extensions present, size, ...
00456  *
00457  * @see iso_image_import()
00458  * @since 0.6.2
00459  */
00460 typedef struct iso_read_image_features IsoReadImageFeatures;
00461 
00462 /**
00463  * POSIX abstraction for source files.
00464  *
00465  * @see struct iso_file_source
00466  * @since 0.6.2
00467  */
00468 typedef struct iso_file_source IsoFileSource;
00469 
00470 /**
00471  * Abstract for source filesystems.
00472  *
00473  * @see struct iso_filesystem
00474  * @since 0.6.2
00475  */
00476 typedef struct iso_filesystem IsoFilesystem;
00477 
00478 /**
00479  * Interface that defines the operations (methods) available for an
00480  * IsoFileSource.
00481  *
00482  * @see struct IsoFileSource_Iface
00483  * @since 0.6.2
00484  */
00485 typedef struct IsoFileSource_Iface IsoFileSourceIface;
00486 
00487 /**
00488  * IsoFilesystem implementation to deal with ISO images, and to offer a way to
00489  * access specific information of the image, such as several volume attributes,
00490  * extensions being used, El-Torito artifacts...
00491  *
00492  * @since 0.6.2
00493  */
00494 typedef IsoFilesystem IsoImageFilesystem;
00495 
00496 /**
00497  * See IsoFilesystem->get_id() for info about this.
00498  * @since 0.6.2
00499  */
00500 extern unsigned int iso_fs_global_id;
00501 
00502 /**
00503  * An IsoFilesystem is a handler for a source of files, or a "filesystem".
00504  * That is defined as a set of files that are organized in a hierarchical
00505  * structure.
00506  *
00507  * A filesystem allows libisofs to access files from several sources in
00508  * an homogeneous way, thus abstracting the underlying operations needed to
00509  * access and read file contents. Note that this doesn't need to be tied
00510  * to the disc filesystem used in the partition being accessed. For example,
00511  * we have an IsoFilesystem implementation to access any mounted filesystem,
00512  * using standard POSIX functions. It is also legal, of course, to implement
00513  * an IsoFilesystem to deal with a specific filesystem over raw partitions.
00514  * That is what we do, for example, to access an ISO Image.
00515  *
00516  * Each file inside an IsoFilesystem is represented as an IsoFileSource object,
00517  * that defines POSIX-like interface for accessing files.
00518  *
00519  * @since 0.6.2
00520  */
00521 struct iso_filesystem
00522 {
00523     /**
00524      * Type of filesystem.
00525      * "file" -> local filesystem
00526      * "iso " -> iso image filesystem
00527      */
00528     char type[4];
00529 
00530     /* reserved for future usage, set to 0 */
00531     int version;
00532 
00533     /**
00534      * Get the root of a filesystem.
00535      *
00536      * @return
00537      *    1 on success, < 0 on error (has to be a valid libisofs error code)
00538      */
00539     int (*get_root)(IsoFilesystem *fs, IsoFileSource **root);
00540 
00541     /**
00542      * Retrieve a file from its absolute path inside the filesystem.
00543      * @param file
00544      *     Returns a pointer to a IsoFileSource object representing the
00545      *     file. It has to be disposed by iso_file_source_unref() when
00546      *     no longer needed.
00547      * @return
00548      *     1 success, < 0 error (has to be a valid libisofs error code)
00549      *      Error codes:
00550      *         ISO_FILE_ACCESS_DENIED
00551      *         ISO_FILE_BAD_PATH
00552      *         ISO_FILE_DOESNT_EXIST
00553      *         ISO_OUT_OF_MEM
00554      *         ISO_FILE_ERROR
00555      *         ISO_NULL_POINTER
00556      */
00557     int (*get_by_path)(IsoFilesystem *fs, const char *path,
00558                        IsoFileSource **file);
00559 
00560     /**
00561      * Get filesystem identifier.
00562      *
00563      * If the filesystem is able to generate correct values of the st_dev
00564      * and st_ino fields for the struct stat of each file, this should
00565      * return an unique number, greater than 0.
00566      *
00567      * To get a identifier for your filesystem implementation you should
00568      * use iso_fs_global_id, incrementing it by one each time.
00569      *
00570      * Otherwise, if you can't ensure values in the struct stat are valid,
00571      * this should return 0.
00572      */
00573     unsigned int (*get_id)(IsoFilesystem *fs);
00574 
00575     /**
00576      * Opens the filesystem for several read operations. Calling this funcion
00577      * is not needed at all, each time that the underlying system resource
00578      * needs to be accessed, it is openned propertly.
00579      * However, if you plan to execute several operations on the filesystem,
00580      * it is a good idea to open it previously, to prevent several open/close
00581      * operations to occur.
00582      *
00583      * @return 1 on success, < 0 on error (has to be a valid libisofs error code)
00584      */
00585     int (*open)(IsoFilesystem *fs);
00586 
00587     /**
00588      * Close the filesystem, thus freeing all system resources. You should
00589      * call this function if you have previously open() it.
00590      * Note that you can open()/close() a filesystem several times.
00591      *
00592      * @return 1 on success, < 0 on error (has to be a valid libisofs error code)
00593      */
00594     int (*close)(IsoFilesystem *fs);
00595 
00596     /**
00597      * Free implementation specific data. Should never be called by user.
00598      * Use iso_filesystem_unref() instead.
00599      */
00600     void (*free)(IsoFilesystem *fs);
00601 
00602     /* internal usage, do never access them directly */
00603     unsigned int refcount;
00604     void *data;
00605 };
00606 
00607 /**
00608  * Interface definition for an IsoFileSource. Defines the POSIX-like function
00609  * to access files and abstract underlying source.
00610  *
00611  * @since 0.6.2
00612  */
00613 struct IsoFileSource_Iface
00614 {
00615     /**
00616      * Tells the version of the interface:
00617      * Version 0 provides functions up to (*lseek)().
00618      * @since 0.6.2
00619      * Version 1 additionally provides function *(get_aa_string)().
00620      * @since 0.6.14
00621      * Version 2 additionally provides function *(clone_src)().
00622      * @since 1.0.2
00623      */
00624     int version;
00625 
00626     /**
00627      * Get the absolute path in the filesystem this file source belongs to.
00628      *
00629      * @return
00630      *     the path of the FileSource inside the filesystem, it should be
00631      *     freed when no more needed.
00632      */
00633     char* (*get_path)(IsoFileSource *src);
00634 
00635     /**
00636      * Get the name of the file, with the dir component of the path.
00637      *
00638      * @return
00639      *     the name of the file, it should be freed when no more needed.
00640      */
00641     char* (*get_name)(IsoFileSource *src);
00642 
00643     /**
00644      * Get information about the file. It is equivalent to lstat(2).
00645      *
00646      * @return
00647      *    1 success, < 0 error (has to be a valid libisofs error code)
00648      *      Error codes:
00649      *         ISO_FILE_ACCESS_DENIED
00650      *         ISO_FILE_BAD_PATH
00651      *         ISO_FILE_DOESNT_EXIST
00652      *         ISO_OUT_OF_MEM
00653      *         ISO_FILE_ERROR
00654      *         ISO_NULL_POINTER
00655      */
00656     int (*lstat)(IsoFileSource *src, struct stat *info);
00657 
00658     /**
00659      * Get information about the file. If the file is a symlink, the info
00660      * returned refers to the destination. It is equivalent to stat(2).
00661      *
00662      * @return
00663      *    1 success, < 0 error
00664      *      Error codes:
00665      *         ISO_FILE_ACCESS_DENIED
00666      *         ISO_FILE_BAD_PATH
00667      *         ISO_FILE_DOESNT_EXIST
00668      *         ISO_OUT_OF_MEM
00669      *         ISO_FILE_ERROR
00670      *         ISO_NULL_POINTER
00671      */
00672     int (*stat)(IsoFileSource *src, struct stat *info);
00673 
00674     /**
00675      * Check if the process has access to read file contents. Note that this
00676      * is not necessarily related with (l)stat functions. For example, in a
00677      * filesystem implementation to deal with an ISO image, if the user has
00678      * read access to the image it will be able to read all files inside it,
00679      * despite of the particular permission of each file in the RR tree, that
00680      * are what the above functions return.
00681      *
00682      * @return
00683      *     1 if process has read access, < 0 on error (has to be a valid
00684      *     libisofs error code)
00685      *      Error codes:
00686      *         ISO_FILE_ACCESS_DENIED
00687      *         ISO_FILE_BAD_PATH
00688      *         ISO_FILE_DOESNT_EXIST
00689      *         ISO_OUT_OF_MEM
00690      *         ISO_FILE_ERROR
00691      *         ISO_NULL_POINTER
00692      */
00693     int (*access)(IsoFileSource *src);
00694 
00695     /**
00696      * Opens the source.
00697      * @return 1 on success, < 0 on error (has to be a valid libisofs error code)
00698      *      Error codes:
00699      *         ISO_FILE_ALREADY_OPENED
00700      *         ISO_FILE_ACCESS_DENIED
00701      *         ISO_FILE_BAD_PATH
00702      *         ISO_FILE_DOESNT_EXIST
00703      *         ISO_OUT_OF_MEM
00704      *         ISO_FILE_ERROR
00705      *         ISO_NULL_POINTER
00706      */
00707     int (*open)(IsoFileSource *src);
00708 
00709     /**
00710      * Close a previuously openned file
00711      * @return 1 on success, < 0 on error
00712      *      Error codes:
00713      *         ISO_FILE_ERROR
00714      *         ISO_NULL_POINTER
00715      *         ISO_FILE_NOT_OPENED
00716      */
00717     int (*close)(IsoFileSource *src);
00718 
00719     /**
00720      * Attempts to read up to count bytes from the given source into
00721      * the buffer starting at buf.
00722      *
00723      * The file src must be open() before calling this, and close() when no
00724      * more needed. Not valid for dirs. On symlinks it reads the destination
00725      * file.
00726      *
00727      * @return
00728      *     number of bytes read, 0 if EOF, < 0 on error (has to be a valid
00729      *     libisofs error code)
00730      *      Error codes:
00731      *         ISO_FILE_ERROR
00732      *         ISO_NULL_POINTER
00733      *         ISO_FILE_NOT_OPENED
00734      *         ISO_WRONG_ARG_VALUE -> if count == 0
00735      *         ISO_FILE_IS_DIR
00736      *         ISO_OUT_OF_MEM
00737      *         ISO_INTERRUPTED
00738      */
00739     int (*read)(IsoFileSource *src, void *buf, size_t count);
00740 
00741     /**
00742      * Read a directory.
00743      *
00744      * Each call to this function will return a new children, until we reach
00745      * the end of file (i.e, no more children), in that case it returns 0.
00746      *
00747      * The dir must be open() before calling this, and close() when no more
00748      * needed. Only valid for dirs.
00749      *
00750      * Note that "." and ".." children MUST NOT BE returned.
00751      *
00752      * @param child
00753      *     pointer to be filled with the given child. Undefined on error or OEF
00754      * @return
00755      *     1 on success, 0 if EOF (no more children), < 0 on error (has to be
00756      *     a valid libisofs error code)
00757      *      Error codes:
00758      *         ISO_FILE_ERROR
00759      *         ISO_NULL_POINTER
00760      *         ISO_FILE_NOT_OPENED
00761      *         ISO_FILE_IS_NOT_DIR
00762      *         ISO_OUT_OF_MEM
00763      */
00764     int (*readdir)(IsoFileSource *src, IsoFileSource **child);
00765 
00766     /**
00767      * Read the destination of a symlink. You don't need to open the file
00768      * to call this.
00769      *
00770      * @param buf
00771      *     allocated buffer of at least bufsiz bytes.
00772      *     The dest. will be copied there, and it will be NULL-terminated
00773      * @param bufsiz
00774      *     characters to be copied. Destination link will be truncated if
00775      *     it is larger than given size. This include the 0x0 character.
00776      * @return
00777      *     1 on success, < 0 on error (has to be a valid libisofs error code)
00778      *      Error codes:
00779      *         ISO_FILE_ERROR
00780      *         ISO_NULL_POINTER
00781      *         ISO_WRONG_ARG_VALUE -> if bufsiz <= 0
00782      *         ISO_FILE_IS_NOT_SYMLINK
00783      *         ISO_OUT_OF_MEM
00784      *         ISO_FILE_BAD_PATH
00785      *         ISO_FILE_DOESNT_EXIST
00786      *
00787      */
00788     int (*readlink)(IsoFileSource *src, char *buf, size_t bufsiz);
00789 
00790     /**
00791      * Get the filesystem for this source. No extra ref is added, so you
00792      * musn't unref the IsoFilesystem.
00793      *
00794      * @return
00795      *     The filesystem, NULL on error
00796      */
00797     IsoFilesystem* (*get_filesystem)(IsoFileSource *src);
00798 
00799     /**
00800      * Free implementation specific data. Should never be called by user.
00801      * Use iso_file_source_unref() instead.
00802      */
00803     void (*free)(IsoFileSource *src);
00804 
00805     /**
00806      * Repositions the offset of the IsoFileSource (must be opened) to the
00807      * given offset according to the value of flag.
00808      *
00809      * @param offset
00810      *      in bytes
00811      * @param flag
00812      *      0 The offset is set to offset bytes (SEEK_SET)
00813      *      1 The offset is set to its current location plus offset bytes
00814      *        (SEEK_CUR)
00815      *      2 The offset is set to the size of the file plus offset bytes
00816      *        (SEEK_END).
00817      * @return
00818      *      Absolute offset position of the file, or < 0 on error. Cast the
00819      *      returning value to int to get a valid libisofs error.
00820      *
00821      * @since 0.6.4
00822      */
00823     off_t (*lseek)(IsoFileSource *src, off_t offset, int flag);
00824 
00825     /* Add-ons of .version 1 begin here */
00826 
00827     /**
00828      * Valid only if .version is > 0. See above.
00829      * Get the AAIP string with encoded ACL and xattr.
00830      * (Not to be confused with ECMA-119 Extended Attributes).
00831      *
00832      * bit1 and bit2 of flag should be implemented so that freshly fetched
00833      * info does not include the undesired ACL or xattr. Nevertheless if the
00834      * aa_string is cached, then it is permissible that ACL and xattr are still
00835      * delivered.
00836      *
00837      * @param flag       Bitfield for control purposes
00838      *                   bit0= Transfer ownership of AAIP string data.
00839      *                         src will free the eventual cached data and might
00840      *                         not be able to produce it again.
00841      *                   bit1= No need to get ACL (no guarantee of exclusion)
00842      *                   bit2= No need to get xattr (no guarantee of exclusion)
00843      * @param aa_string  Returns a pointer to the AAIP string data. If no AAIP
00844      *                   string is available, *aa_string becomes NULL.
00845      *                   (See doc/susp_aaip_*_*.txt for the meaning of AAIP and
00846      *                    libisofs/aaip_0_2.h for encoding and decoding.)
00847      *                   The caller is responsible for finally calling free()
00848      *                   on non-NULL results.
00849      * @return           1 means success (*aa_string == NULL is possible)
00850      *                  <0 means failure and must b a valid libisofs error code
00851      *                     (e.g. ISO_FILE_ERROR if no better one can be found).
00852      * @since 0.6.14
00853      */
00854     int (*get_aa_string)(IsoFileSource *src,
00855                                      unsigned char **aa_string, int flag);
00856 
00857     /**
00858      * Produce a copy of a source. It must be possible to operate both source
00859      * objects concurrently.
00860      * 
00861      * @param old_src
00862      *     The existing source object to be copied
00863      * @param new_stream
00864      *     Will return a pointer to the copy
00865      * @param flag
00866      *     Bitfield for control purposes. Submit 0 for now.
00867      *     The function shall return ISO_STREAM_NO_CLONE on unknown flag bits.
00868      *
00869      * @since 1.0.2
00870      * Present if .version is 2 or higher.
00871      */
00872     int (*clone_src)(IsoFileSource *old_src, IsoFileSource **new_src, 
00873                      int flag);
00874 
00875     /*
00876      * TODO #00004 Add a get_mime_type() function.
00877      * This can be useful for GUI apps, to choose the icon of the file
00878      */
00879 };
00880 
00881 #ifndef __cplusplus
00882 #ifndef Libisofs_h_as_cpluspluS
00883 
00884 /**
00885  * An IsoFile Source is a POSIX abstraction of a file.
00886  *
00887  * @since 0.6.2
00888  */
00889 struct iso_file_source
00890 {
00891     const IsoFileSourceIface *class;
00892     int refcount;
00893     void *data;
00894 };
00895 
00896 #endif /* ! Libisofs_h_as_cpluspluS */
00897 #endif /* ! __cplusplus */
00898 
00899 
00900 /* A class of IsoStream is implemented by a class description
00901  *    IsoStreamIface = struct IsoStream_Iface
00902  * and a structure of data storage for each instance of IsoStream.
00903  * This structure shall be known to the functions of the IsoStreamIface.
00904  * To create a custom IsoStream class:
00905  * - Define the structure of the custom instance data.
00906  * - Implement the methods which are described by the definition of
00907  *   struct IsoStream_Iface (see below),
00908  * - Create a static instance of IsoStreamIface which lists the methods as
00909  *   C function pointers. (Example in libisofs/stream.c : fsrc_stream_class)
00910  * To create an instance of that class:
00911  * - Allocate sizeof(IsoStream) bytes of memory and initialize it as
00912  *   struct iso_stream :
00913  *   - Point to the custom IsoStreamIface by member .class .
00914  *   - Set member .refcount to 1.
00915  *   - Let member .data point to the custom instance data.
00916  *
00917  * Regrettably the choice of the structure member name "class" makes it
00918  * impossible to implement this generic interface in C++ language directly.
00919  * If C++ is absolutely necessary then you will have to make own copies
00920  * of the public API structures. Use other names but take care to maintain
00921  * the same memory layout.
00922  */
00923 
00924 /**
00925  * Representation of file contents. It is an stream of bytes, functionally
00926  * like a pipe.
00927  *
00928  * @since 0.6.4
00929  */
00930 typedef struct iso_stream IsoStream;
00931 
00932 /**
00933  * Interface that defines the operations (methods) available for an
00934  * IsoStream.
00935  *
00936  * @see struct IsoStream_Iface
00937  * @since 0.6.4
00938  */
00939 typedef struct IsoStream_Iface IsoStreamIface;
00940 
00941 /**
00942  * Serial number to be used when you can't get a valid id for a Stream by other
00943  * means. If you use this, both fs_id and dev_id should be set to 0.
00944  * This must be incremented each time you get a reference to it.
00945  *
00946  * @see IsoStreamIface->get_id()
00947  * @since 0.6.4
00948  */
00949 extern ino_t serial_id;
00950 
00951 /**
00952  * Interface definition for IsoStream methods. It is public to allow
00953  * implementation of own stream types.
00954  * The methods defined here typically make use of stream.data which points
00955  * to the individual state data of stream instances.
00956  * 
00957  * @since 0.6.4
00958  */
00959 
00960 struct IsoStream_Iface
00961 {
00962     /*
00963      * Current version of the interface.
00964      * Version 0 (since 0.6.4)
00965      *    deprecated but still valid.
00966      * Version 1 (since 0.6.8) 
00967      *    update_size() added.
00968      * Version 2 (since 0.6.18)
00969      *    get_input_stream() added.
00970      *    A filter stream must have version 2 at least.
00971      * Version 3 (since 0.6.20)
00972      *    compare() added.
00973      *    A filter stream should have version 3 at least.
00974      * Version 4 (since 1.0.2)
00975      *    clone_stream() added.
00976      */
00977     int version;
00978 
00979     /**
00980      * Type of Stream.
00981      * "fsrc" -> Read from file source
00982      * "cout" -> Cut out interval from disk file
00983      * "mem " -> Read from memory
00984      * "boot" -> Boot catalog
00985      * "extf" -> External filter program
00986      * "ziso" -> zisofs compression
00987      * "osiz" -> zisofs uncompression
00988      * "gzip" -> gzip compression
00989      * "pizg" -> gzip uncompression (gunzip)
00990      * "user" -> User supplied stream
00991      */
00992     char type[4];
00993 
00994     /**
00995      * Opens the stream.
00996      *
00997      * @return
00998      *     1 on success, 2 file greater than expected, 3 file smaller than
00999      *     expected, < 0 on error (has to be a valid libisofs error code)
01000      */
01001     int (*open)(IsoStream *stream);
01002 
01003     /**
01004      * Close the Stream.
01005      * @return
01006      *     1 on success, < 0 on error (has to be a valid libisofs error code)
01007      */
01008     int (*close)(IsoStream *stream);
01009 
01010     /**
01011      * Get the size (in bytes) of the stream. This function should always
01012      * return the same size, even if the underlying source size changes,
01013      * unless you call update_size() method.
01014      */
01015     off_t (*get_size)(IsoStream *stream);
01016 
01017     /**
01018      * Attempt to read up to count bytes from the given stream into
01019      * the buffer starting at buf. The implementation has to make sure that
01020      * either the full desired count of bytes is delivered or that the
01021      * next call to this function will return EOF or error.
01022      * I.e. only the last read block may be shorter than parameter count.
01023      *
01024      * The stream must be open() before calling this, and close() when no
01025      * more needed.
01026      *
01027      * @return
01028      *     number of bytes read, 0 if EOF, < 0 on error (has to be a valid
01029      *     libisofs error code)
01030      */
01031     int (*read)(IsoStream *stream, void *buf, size_t count);
01032 
01033     /**
01034      * Tell whether this IsoStream can be read several times, with the same
01035      * results. For example, a regular file is repeatable, you can read it
01036      * as many times as you want. However, a pipe is not.
01037      *
01038      * @return
01039      *     1 if stream is repeatable, 0 if not,
01040      *     < 0 on error (has to be a valid libisofs error code)
01041      */
01042     int (*is_repeatable)(IsoStream *stream);
01043 
01044     /**
01045      * Get an unique identifier for the IsoStream.
01046      */
01047     void (*get_id)(IsoStream *stream, unsigned int *fs_id, dev_t *dev_id,
01048                   ino_t *ino_id);
01049 
01050     /**
01051      * Free implementation specific data. Should never be called by user.
01052      * Use iso_stream_unref() instead.
01053      */
01054     void (*free)(IsoStream *stream);
01055 
01056     /**
01057      * Update the size of the IsoStream with the current size of the underlying
01058      * source, if the source is prone to size changes. After calling this,
01059      * get_size() shall eventually return the new size.
01060      * This will never be called after iso_image_create_burn_source() was
01061      * called and before the image was completely written.
01062      * (The API call to update the size of all files in the image is
01063      *  iso_image_update_sizes()).
01064      *
01065      * @return
01066      *     1 if ok, < 0 on error (has to be a valid libisofs error code)
01067      *
01068      * @since 0.6.8
01069      * Present if .version is 1 or higher.
01070      */
01071     int (*update_size)(IsoStream *stream);
01072 
01073     /**
01074      * Retrieve the eventual input stream of a filter stream.
01075      *
01076      * @param stream
01077      *     The eventual filter stream to be inquired.
01078      * @param flag
01079      *     Bitfield for control purposes. 0 means normal behavior.
01080      * @return
01081      *     The input stream, if one exists. Elsewise NULL.
01082      *     No extra reference to the stream shall be taken by this call.
01083      *
01084      * @since 0.6.18
01085      * Present if .version is 2 or higher.
01086      */
01087     IsoStream *(*get_input_stream)(IsoStream *stream, int flag);
01088 
01089     /**
01090      * Compare two streams whether they are based on the same input and will
01091      * produce the same output. If in any doubt, then this comparison should
01092      * indicate no match. A match might allow hardlinking of IsoFile objects.
01093      *
01094      * If this function cannot accept one of the given stream types, then
01095      * the decision must be delegated to
01096      *    iso_stream_cmp_ino(s1, s2, 1);
01097      * This is also appropriate if one has reason to implement stream.cmp_ino()
01098      * without having an own special comparison algorithm.
01099      *
01100      * With filter streams, the decision whether the underlying chains of
01101      * streams match, should be delegated to
01102      *    iso_stream_cmp_ino(iso_stream_get_input_stream(s1, 0),
01103      *                       iso_stream_get_input_stream(s2, 0), 0);
01104      *
01105      * The stream.cmp_ino() function has to establish an equivalence and order
01106      * relation: 
01107      *   cmp_ino(A,A) == 0
01108      *   cmp_ino(A,B) == -cmp_ino(B,A) 
01109      *   if cmp_ino(A,B) == 0 && cmp_ino(B,C) == 0 then cmp_ino(A,C) == 0
01110      *   if cmp_ino(A,B) < 0 && cmp_ino(B,C) < 0 then cmp_ino(A,C) < 0
01111      *
01112      * A big hazard to the last constraint are tests which do not apply to some 
01113      * types of streams.Thus it is mandatory to let iso_stream_cmp_ino(s1,s2,1)
01114      * decide in this case.
01115      *
01116      * A function s1.(*cmp_ino)() must only accept stream s2 if function
01117      * s2.(*cmp_ino)() would accept s1. Best is to accept only the own stream
01118      * type or to have the same function for a family of similar stream types.
01119      *
01120      * @param s1
01121      *     The first stream to compare. Expect foreign stream types.
01122      * @param s2
01123      *     The second stream to compare. Expect foreign stream types.
01124      * @return
01125      *     -1 if s1 is smaller s2 , 0 if s1 matches s2 , 1 if s1 is larger s2
01126      *
01127      * @since 0.6.20
01128      * Present if .version is 3 or higher.
01129      */
01130     int (*cmp_ino)(IsoStream *s1, IsoStream *s2);
01131 
01132     /**
01133      * Produce a copy of a stream. It must be possible to operate both stream
01134      * objects concurrently.
01135      * 
01136      * @param old_stream
01137      *     The existing stream object to be copied
01138      * @param new_stream
01139      *     Will return a pointer to the copy
01140      * @param flag
01141      *     Bitfield for control purposes. 0 means normal behavior.
01142      *     The function shall return ISO_STREAM_NO_CLONE on unknown flag bits.
01143      * @return
01144      *     1 in case of success, or an error code < 0
01145      *
01146      * @since 1.0.2
01147      * Present if .version is 4 or higher.
01148      */
01149     int (*clone_stream)(IsoStream *old_stream, IsoStream **new_stream,
01150                         int flag);
01151 
01152 };
01153 
01154 #ifndef __cplusplus
01155 #ifndef Libisofs_h_as_cpluspluS
01156 
01157 /**
01158  * Representation of file contents as a stream of bytes.
01159  *
01160  * @since 0.6.4
01161  */
01162 struct iso_stream
01163 {
01164     IsoStreamIface *class;
01165     int refcount;
01166     void *data;
01167 };
01168 
01169 #endif /* ! Libisofs_h_as_cpluspluS */
01170 #endif /* ! __cplusplus */
01171 
01172 
01173 /**
01174  * Initialize libisofs. Before any usage of the library you must either call
01175  * this function or iso_init_with_flag().
01176  * Only exception from this rule: iso_lib_version(), iso_lib_is_compatible().
01177  * @return 1 on success, < 0 on error
01178  *
01179  * @since 0.6.2
01180  */
01181 int iso_init();
01182 
01183 /**
01184  * Initialize libisofs. Before any usage of the library you must either call
01185  * this function or iso_init() which is equivalent to iso_init_with_flag(0).
01186  * Only exception from this rule: iso_lib_version(), iso_lib_is_compatible().
01187  * @param flag
01188  *      Bitfield for control purposes
01189  *      bit0= do not set up locale by LC_* environment variables
01190  * @return 1 on success, < 0 on error
01191  *
01192  * @since 0.6.18
01193  */
01194 int iso_init_with_flag(int flag);
01195 
01196 /**
01197  * Finalize libisofs.
01198  *
01199  * @since 0.6.2
01200  */
01201 void iso_finish();
01202 
01203 /**
01204  * Override the reply of libc function nl_langinfo(CODESET) which may or may
01205  * not give the name of the character set which is in effect for your
01206  * environment. So this call can compensate for inconsistent terminal setups.
01207  * Another use case is to choose UTF-8 as intermediate character set for a
01208  * conversion from an exotic input character set to an exotic output set.
01209  *
01210  * @param name
01211  *     Name of the character set to be assumed as "local" one.
01212  * @param flag
01213  *     Unused yet. Submit 0.
01214  * @return
01215  *     1 indicates success, <=0 failure
01216  *
01217  * @since 0.6.12
01218  */
01219 int iso_set_local_charset(char *name, int flag);
01220 
01221 /**
01222  * Obtain the local charset as currently assumed by libisofs.
01223  * The result points to internal memory. It is volatile and must not be
01224  * altered.
01225  *
01226  * @param flag
01227  *     Unused yet. Submit 0.
01228  *
01229  * @since 0.6.12
01230  */
01231 char *iso_get_local_charset(int flag);
01232 
01233 /**
01234  * Create a new image, empty.
01235  *
01236  * The image will be owned by you and should be unref() when no more needed.
01237  *
01238  * @param name
01239  *     Name of the image. This will be used as volset_id and volume_id.
01240  * @param image
01241  *     Location where the image pointer will be stored.
01242  * @return
01243  *     1 sucess, < 0 error
01244  *
01245  * @since 0.6.2
01246  */
01247 int iso_image_new(const char *name, IsoImage **image);
01248 
01249 
01250 /**
01251  * Control whether ACL and xattr will be imported from external filesystems
01252  * (typically the local POSIX filesystem) when new nodes get inserted. If
01253  * enabled by iso_write_opts_set_aaip() they will later be written into the
01254  * image as AAIP extension fields.
01255  *
01256  * A change of this setting does neither affect existing IsoNode objects
01257  * nor the way how ACL and xattr are handled when loading an ISO image.
01258  * The latter is controlled by iso_read_opts_set_no_aaip().
01259  *
01260  * @param image
01261  *     The image of which the behavior is to be controlled
01262  * @param what
01263  *     A bit field which sets the behavior:
01264  *     bit0= ignore ACLs if the external file object bears some
01265  *     bit1= ignore xattr if the external file object bears some
01266  *     all other bits are reserved
01267  *
01268  * @since 0.6.14
01269  */
01270 void iso_image_set_ignore_aclea(IsoImage *image, int what);
01271 
01272 
01273 /**
01274  * Creates an IsoWriteOpts for writing an image. You should set the options
01275  * desired with the correspondent setters.
01276  *
01277  * Options by default are determined by the selected profile. Fifo size is set
01278  * by default to 2 MB.
01279  *
01280  * @param opts
01281  *     Pointer to the location where the newly created IsoWriteOpts will be
01282  *     stored. You should free it with iso_write_opts_free() when no more
01283  *     needed.
01284  * @param profile
01285  *     Default profile for image creation. For now the following values are
01286  *     defined:
01287  *     ---> 0 [BASIC]
01288  *        No extensions are enabled, and ISO level is set to 1. Only suitable
01289  *        for usage for very old and limited systems (like MS-DOS), or by a
01290  *        start point from which to set your custom options.
01291  *     ---> 1 [BACKUP]
01292  *        POSIX compatibility for backup. Simple settings, ISO level is set to
01293  *        3 and RR extensions are enabled. Useful for backup purposes.
01294  *        Note that ACL and xattr are not enabled by default.
01295  *        If you enable them, expect them not to show up in the mounted image.
01296  *        They will have to be retrieved by libisofs applications like xorriso.
01297  *     ---> 2 [DISTRIBUTION]
01298  *        Setting for information distribution. Both RR and Joliet are enabled
01299  *        to maximize compatibility with most systems. Permissions are set to
01300  *        default values, and timestamps to the time of recording.
01301  * @return
01302  *      1 success, < 0 error
01303  *
01304  * @since 0.6.2
01305  */
01306 int iso_write_opts_new(IsoWriteOpts **opts, int profile);
01307 
01308 /**
01309  * Free an IsoWriteOpts previously allocated with iso_write_opts_new().
01310  *
01311  * @since 0.6.2
01312  */
01313 void iso_write_opts_free(IsoWriteOpts *opts);
01314 
01315 /**
01316  * Announce that only the image size is desired, that the struct burn_source
01317  * which is set to consume the image output stream will stay inactive,
01318  * and that the write thread will be cancelled anyway by the .cancel() method
01319  * of the struct burn_source.
01320  * This avoids to create a write thread which would begin production of the
01321  * image stream and would generate a MISHAP event when burn_source.cancel()
01322  * gets into effect.
01323  * 
01324  * @param opts
01325  *      The option set to be manipulated.
01326  * @param will_cancel
01327  *      0= normal image generation
01328  *      1= prepare for being canceled before image stream output is completed
01329  * @return
01330  *      1 success, < 0 error
01331  *
01332  * @since 0.6.40
01333  */
01334 int iso_write_opts_set_will_cancel(IsoWriteOpts *opts, int will_cancel);
01335 
01336 /**
01337  * Set the ISO-9960 level to write at.
01338  *
01339  * @param opts
01340  *      The option set to be manipulated.
01341  * @param level
01342  *      -> 1 for higher compatibility with old systems. With this level
01343  *      filenames are restricted to 8.3 characters.
01344  *      -> 2 to allow up to 31 filename characters.
01345  *      -> 3 to allow files greater than 4GB
01346  * @return
01347  *      1 success, < 0 error
01348  *
01349  * @since 0.6.2
01350  */
01351 int iso_write_opts_set_iso_level(IsoWriteOpts *opts, int level);
01352 
01353 /**
01354  * Whether to use or not Rock Ridge extensions.
01355  *
01356  * This are standard extensions to ECMA-119, intended to add POSIX filesystem
01357  * features to ECMA-119 images. Thus, usage of this flag is highly recommended
01358  * for images used on GNU/Linux systems. With the usage of RR extension, the
01359  * resulting image will have long filenames (up to 255 characters), deeper
01360  * directory structure, POSIX permissions and owner info on files and
01361  * directories, support for symbolic links or special files... All that
01362  * attributes can be modified/setted with the appropiate function.
01363  *
01364  * @param opts
01365  *      The option set to be manipulated.
01366  * @param enable
01367  *      1 to enable RR extension, 0 to not add them
01368  * @return
01369  *      1 success, < 0 error
01370  *
01371  * @since 0.6.2
01372  */
01373 int iso_write_opts_set_rockridge(IsoWriteOpts *opts, int enable);
01374 
01375 /**
01376  * Whether to add the non-standard Joliet extension to the image.
01377  *
01378  * This extensions are heavily used in Microsoft Windows systems, so if you
01379  * plan to use your disc on such a system you should add this extension.
01380  * Usage of Joliet supplies longer filesystem length (up to 64 unicode
01381  * characters), and deeper directory structure.
01382  *
01383  * @param opts
01384  *      The option set to be manipulated.
01385  * @param enable
01386  *      1 to enable Joliet extension, 0 to not add them
01387  * @return
01388  *      1 success, < 0 error
01389  *
01390  * @since 0.6.2
01391  */
01392 int iso_write_opts_set_joliet(IsoWriteOpts *opts, int enable);
01393 
01394 /**
01395  * Whether to use newer ISO-9660:1999 version.
01396  *
01397  * This is the second version of ISO-9660. It allows longer filenames and has
01398  * less restrictions than old ISO-9660. However, nobody is using it so there
01399  * are no much reasons to enable this.
01400  *
01401  * @since 0.6.2
01402  */
01403 int iso_write_opts_set_iso1999(IsoWriteOpts *opts, int enable);
01404 
01405 /**
01406  * Control generation of non-unique inode numbers for the emerging image.
01407  * Inode numbers get written as "file serial number" with PX entries as of
01408  * RRIP-1.12. They may mark families of hardlinks.
01409  * RRIP-1.10 prescribes a PX entry without file serial number. If not overriden
01410  * by iso_write_opts_set_rrip_1_10_px_ino() there will be no file serial number
01411  * written into RRIP-1.10 images.
01412  *
01413  * Inode number generation does not affect IsoNode objects which imported their
01414  * inode numbers from the old ISO image (see iso_read_opts_set_new_inos())
01415  * and which have not been altered since import. It rather applies to IsoNode
01416  * objects which were newly added to the image, or to IsoNode which brought no
01417  * inode number from the old image, or to IsoNode where certain properties 
01418  * have been altered since image import.
01419  *
01420  * If two IsoNode are found with same imported inode number but differing
01421  * properties, then one of them will get assigned a new unique inode number.
01422  * I.e. the hardlink relation between both IsoNode objects ends.
01423  *
01424  * @param opts
01425  *      The option set to be manipulated.
01426  * @param enable 
01427  *      1 = Collect IsoNode objects which have identical data sources and
01428  *          properties.
01429  *      0 = Generate unique inode numbers for all IsoNode objects which do not
01430  *          have a valid inode number from an imported ISO image.
01431  *      All other values are reserved.
01432  *
01433  * @since 0.6.20
01434  */
01435 int iso_write_opts_set_hardlinks(IsoWriteOpts *opts, int enable);
01436 
01437 /**
01438  * Control writing of AAIP informations for ACL and xattr.
01439  * For importing ACL and xattr when inserting nodes from external filesystems
01440  * (e.g. the local POSIX filesystem) see iso_image_set_ignore_aclea().
01441  * For loading of this information from images see iso_read_opts_set_no_aaip().
01442  *
01443  * @param opts
01444  *      The option set to be manipulated.
01445  * @param enable
01446  *      1 = write AAIP information from nodes into the image
01447  *      0 = do not write AAIP information into the image
01448  *      All other values are reserved.
01449  *
01450  * @since 0.6.14
01451  */
01452 int iso_write_opts_set_aaip(IsoWriteOpts *opts, int enable);
01453 
01454 /**
01455  * Use this only if you need to reproduce a suboptimal behavior of older
01456  * versions of libisofs. They used address 0 for links and device files,
01457  * and the address of the Volume Descriptor Set Terminator for empty data
01458  * files.
01459  * New versions let symbolic links, device files, and empty data files point
01460  * to a dedicated block of zero-bytes after the end of the directory trees.
01461  * (Single-pass reader libarchive needs to see all directory info before
01462  *  processing any data files.)
01463  *
01464  * @param opts
01465  *      The option set to be manipulated.
01466  * @param enable
01467  *      1 = use the suboptimal block addresses in the range of 0 to 115.
01468  *      0 = use the address of a block after the directory tree. (Default)
01469  *
01470  * @since 1.0.2
01471  */
01472 int iso_write_opts_set_old_empty(IsoWriteOpts *opts, int enable);
01473 
01474 /**
01475  * Caution: This option breaks any assumptions about names that
01476  *          are supported by ECMA-119 specifications. 
01477  * Try to omit any translation which would make a file name compliant to the
01478  * ECMA-119 rules. This includes and exceeds omit_version_numbers,
01479  * max_37_char_filenames, no_force_dots bit0, allow_full_ascii. Further it
01480  * prevents the conversion from local character set to ASCII.
01481  * The maximum name length is given by this call. If a filename exceeds
01482  * this length or cannot be recorded untranslated for other reasons, then
01483  * image production is aborted with ISO_NAME_NEEDS_TRANSL.
01484  * Currently the length limit is 96 characters, because an ECMA-119 directory
01485  * record may at most have 254 bytes and up to 158 other bytes must fit into
01486  * the record. Probably 96 more bytes can be made free for the name in future.
01487  * @param opts
01488  *      The option set to be manipulated.
01489  * @param len
01490  *      0 = disable this feature and perform name translation according to
01491  *          other settings.
01492  *     >0 = Omit any translation. Eventually abort image production
01493  *          if a name is longer than the given value.
01494  *     -1 = Like >0. Allow maximum possible length (currently 96)
01495  * @return >=0 success, <0 failure
01496  *         In case of >=0 the return value tells the effectively set len.
01497  *         E.g. 96 after using len == -1.
01498  * @since 1.0.0
01499  */
01500 int iso_write_opts_set_untranslated_name_len(IsoWriteOpts *opts, int len);
01501 
01502 /**
01503  * Convert directory names for ECMA-119 similar to other file names, but do
01504  * not force a dot or add a version number.
01505  * This violates ECMA-119 by allowing one "." and especially ISO level 1 
01506  * by allowing DOS style 8.3 names rather than only 8 characters.
01507  * (mkisofs and its clones seem to do this violation.)
01508  * @param opts
01509  *      The option set to be manipulated.
01510  * @param allow
01511  *      1= allow dots , 0= disallow dots and convert them
01512  * @return
01513  *      1 success, < 0 error
01514  * @since 1.0.0
01515  */
01516 int iso_write_opts_set_allow_dir_id_ext(IsoWriteOpts *opts, int allow);
01517 
01518 /**
01519  * Omit the version number (";1") at the end of the ISO-9660 identifiers.
01520  * This breaks ECMA-119 specification, but version numbers are usually not
01521  * used, so it should work on most systems. Use with caution.
01522  * @param opts
01523  *      The option set to be manipulated.
01524  * @param omit
01525  *      bit0= omit version number with ECMA-119 and Joliet
01526  *      bit1= omit version number with Joliet alone (@since 0.6.30)
01527  * @since 0.6.2
01528  */
01529 int iso_write_opts_set_omit_version_numbers(IsoWriteOpts *opts, int omit);
01530 
01531 /**
01532  * Allow ISO-9660 directory hierarchy to be deeper than 8 levels.
01533  * This breaks ECMA-119 specification. Use with caution.
01534  *
01535  * @since 0.6.2
01536  */
01537 int iso_write_opts_set_allow_deep_paths(IsoWriteOpts *opts, int allow);
01538 
01539 /**
01540  * Allow path in the ISO-9660 tree to have more than 255 characters.
01541  * This breaks ECMA-119 specification. Use with caution.
01542  *
01543  * @since 0.6.2
01544  */
01545 int iso_write_opts_set_allow_longer_paths(IsoWriteOpts *opts, int allow);
01546 
01547 /**
01548  * Allow a single file or directory hierarchy to have up to 37 characters.
01549  * This is larger than the 31 characters allowed by ISO level 2, and the
01550  * extra space is taken from the version number, so this also forces
01551  * omit_version_numbers.
01552  * This breaks ECMA-119 specification and could lead to buffer overflow
01553  * problems on old systems. Use with caution.
01554  *
01555  * @since 0.6.2
01556  */
01557 int iso_write_opts_set_max_37_char_filenames(IsoWriteOpts *opts, int allow);
01558 
01559 /**
01560  * ISO-9660 forces filenames to have a ".", that separates file name from
01561  * extension. libisofs adds it if original filename doesn't has one. Set
01562  * this to 1 to prevent this behavior.
01563  * This breaks ECMA-119 specification. Use with caution.
01564  *
01565  * @param opts
01566  *      The option set to be manipulated.
01567  * @param no
01568  *      bit0= no forced dot with ECMA-119
01569  *      bit1= no forced dot with Joliet (@since 0.6.30)
01570  *
01571  * @since 0.6.2
01572  */
01573 int iso_write_opts_set_no_force_dots(IsoWriteOpts *opts, int no);
01574 
01575 /**
01576  * Allow lowercase characters in ISO-9660 filenames. By default, only
01577  * uppercase characters, numbers and a few other characters are allowed.
01578  * This breaks ECMA-119 specification. Use with caution.
01579  *
01580  * @since 0.6.2
01581  */
01582 int iso_write_opts_set_allow_lowercase(IsoWriteOpts *opts, int allow);
01583 
01584 /**
01585  * Allow all ASCII characters to be appear on an ISO-9660 filename. Note
01586  * that "/" and 0x0 characters are never allowed, even in RR names.
01587  * This breaks ECMA-119 specification. Use with caution.
01588  *
01589  * @since 0.6.2
01590  */
01591 int iso_write_opts_set_allow_full_ascii(IsoWriteOpts *opts, int allow);
01592 
01593 /**
01594  * Allow all characters to be part of Volume and Volset identifiers on
01595  * the Primary Volume Descriptor. This breaks ISO-9660 contraints, but
01596  * should work on modern systems.
01597  *
01598  * @since 0.6.2
01599  */
01600 int iso_write_opts_set_relaxed_vol_atts(IsoWriteOpts *opts, int allow);
01601 
01602 /**
01603  * Allow paths in the Joliet tree to have more than 240 characters.
01604  * This breaks Joliet specification. Use with caution.
01605  *
01606  * @since 0.6.2
01607  */
01608 int iso_write_opts_set_joliet_longer_paths(IsoWriteOpts *opts, int allow);
01609 
01610 /**
01611  * Allow leaf names in the Joliet tree to have up to 103 characters.
01612  * Normal limit is 64. 
01613  * This breaks Joliet specification. Use with caution.
01614  *
01615  * @since 1.0.6
01616  */
01617 int iso_write_opts_set_joliet_long_names(IsoWriteOpts *opts, int allow);
01618 
01619 /**
01620  * Write Rock Ridge info as of specification RRIP-1.10 rather than RRIP-1.12:
01621  * signature "RRIP_1991A" rather than "IEEE_1282", field PX without file
01622  * serial number.
01623  *
01624  * @since 0.6.12
01625  */
01626 int iso_write_opts_set_rrip_version_1_10(IsoWriteOpts *opts, int oldvers);
01627 
01628 /**
01629  * Write field PX with file serial number (i.e. inode number) even if
01630  * iso_write_opts_set_rrip_version_1_10(,1) is in effect.
01631  * This clearly violates the RRIP-1.10 specs. But it is done by mkisofs since
01632  * a while and no widespread protest is visible in the web.
01633  * If this option is not enabled, then iso_write_opts_set_hardlinks() will
01634  * only have an effect with iso_write_opts_set_rrip_version_1_10(,0).
01635  * 
01636  * @since 0.6.20
01637  */
01638 int iso_write_opts_set_rrip_1_10_px_ino(IsoWriteOpts *opts, int enable);
01639 
01640 /**
01641  * Write AAIP as extension according to SUSP 1.10 rather than SUSP 1.12.
01642  * I.e. without announcing it by an ER field and thus without the need
01643  * to preceed the RRIP fields and the AAIP field by ES fields.
01644  * This saves 5 to 10 bytes per file and might avoid problems with readers
01645  * which dislike ER fields other than the ones for RRIP.
01646  * On the other hand, SUSP 1.12 frowns on such unannounced extensions 
01647  * and prescribes ER and ES. It does this since the year 1994.
01648  *
01649  * In effect only if above iso_write_opts_set_aaip() enables writing of AAIP.
01650  *
01651  * @since 0.6.14
01652  */
01653 int iso_write_opts_set_aaip_susp_1_10(IsoWriteOpts *opts, int oldvers);
01654 
01655 /**
01656  * Store as ECMA-119 Directory Record timestamp the mtime of the source
01657  * rather than the image creation time.
01658  *
01659  * @since 0.6.12
01660  */
01661 int iso_write_opts_set_dir_rec_mtime(IsoWriteOpts *opts, int allow);
01662 
01663 /**
01664  * Whether to sort files based on their weight.
01665  *
01666  * @see iso_node_set_sort_weight
01667  * @since 0.6.2
01668  */
01669 int iso_write_opts_set_sort_files(IsoWriteOpts *opts, int sort);
01670 
01671 /**
01672  * Whether to compute and record MD5 checksums for the whole session and/or
01673  * for each single IsoFile object. The checksums represent the data as they
01674  * were written into the image output stream, not necessarily as they were
01675  * on hard disk at any point of time.
01676  * See also calls iso_image_get_session_md5() and iso_file_get_md5().
01677  * @param opts
01678  *      The option set to be manipulated.
01679  * @param session
01680  *      If bit0 set: Compute session checksum
01681  * @param files
01682  *      If bit0 set: Compute a checksum for each single IsoFile object which
01683  *                   gets its data content written into the session. Copy
01684  *                   checksums from files which keep their data in older
01685  *                   sessions.
01686  *      If bit1 set: Check content stability (only with bit0). I.e.  before
01687  *                   writing the file content into to image stream, read it
01688  *                   once and compute a MD5. Do a second reading for writing
01689  *                   into the image stream. Afterwards compare both MD5 and
01690  *                   issue a MISHAP event ISO_MD5_STREAM_CHANGE if they do not
01691  *                   match.
01692  *                   Such a mismatch indicates content changes between the
01693  *                   time point when the first MD5 reading started and the
01694  *                   time point when the last block was read for writing.
01695  *                   So there is high risk that the image stream was fed from
01696  *                   changing and possibly inconsistent file content.
01697  *                   
01698  * @since 0.6.22
01699  */
01700 int iso_write_opts_set_record_md5(IsoWriteOpts *opts, int session, int files);
01701 
01702 /**
01703  * Set the parameters "name" and "timestamp" for a scdbackup checksum tag.
01704  * It will be appended to the libisofs session tag if the image starts at
01705  * LBA 0 (see iso_write_opts_set_ms_block()). The scdbackup tag can be used
01706  * to verify the image by command scdbackup_verify device -auto_end.
01707  * See scdbackup/README appendix VERIFY for its inner details.
01708  *
01709  * @param opts
01710  *      The option set to be manipulated.
01711  * @param name
01712  *      A word of up to 80 characters. Typically volno_totalno telling
01713  *      that this is volume volno of a total of totalno volumes.
01714  * @param timestamp
01715  *      A string of 13 characters YYMMDD.hhmmss (e.g. A90831.190324).
01716  *      A9 = 2009, B0 = 2010, B1 = 2011, ... C0 = 2020, ...
01717  * @param tag_written
01718  *      Either NULL or the address of an array with at least 512 characters.
01719  *      In the latter case the eventually produced scdbackup tag will be
01720  *      copied to this array when the image gets written. This call sets
01721  *      scdbackup_tag_written[0] = 0 to mark its preliminary invalidity.
01722  * @return
01723  *      1 indicates success, <0 is error
01724  *
01725  * @since 0.6.24
01726  */
01727 int iso_write_opts_set_scdbackup_tag(IsoWriteOpts *opts,
01728                                      char *name, char *timestamp,
01729                                      char *tag_written);
01730 
01731 /**
01732  * Whether to set default values for files and directory permissions, gid and
01733  * uid. All these take one of three values: 0, 1 or 2.
01734  *
01735  * If 0, the corresponding attribute will be kept as set in the IsoNode.
01736  * Unless you have changed it, it corresponds to the value on disc, so it
01737  * is suitable for backup purposes. If set to 1, the corresponding attrib.
01738  * will be changed by a default suitable value. Finally, if you set it to
01739  * 2, the attrib. will be changed with the value specified by the functioins
01740  * below. Note that for mode attributes, only the permissions are set, the
01741  * file type remains unchanged.
01742  *
01743  * @see iso_write_opts_set_default_dir_mode
01744  * @see iso_write_opts_set_default_file_mode
01745  * @see iso_write_opts_set_default_uid
01746  * @see iso_write_opts_set_default_gid
01747  * @since 0.6.2
01748  */
01749 int iso_write_opts_set_replace_mode(IsoWriteOpts *opts, int dir_mode,
01750                                     int file_mode, int uid, int gid);
01751 
01752 /**
01753  * Set the mode to use on dirs when you set the replace_mode of dirs to 2.
01754  *
01755  * @see iso_write_opts_set_replace_mode
01756  * @since 0.6.2
01757  */
01758 int iso_write_opts_set_default_dir_mode(IsoWriteOpts *opts, mode_t dir_mode);
01759 
01760 /**
01761  * Set the mode to use on files when you set the replace_mode of files to 2.
01762  *
01763  * @see iso_write_opts_set_replace_mode
01764  * @since 0.6.2
01765  */
01766 int iso_write_opts_set_default_file_mode(IsoWriteOpts *opts, mode_t file_mode);
01767 
01768 /**
01769  * Set the uid to use when you set the replace_uid to 2.
01770  *
01771  * @see iso_write_opts_set_replace_mode
01772  * @since 0.6.2
01773  */
01774 int iso_write_opts_set_default_uid(IsoWriteOpts *opts, uid_t uid);
01775 
01776 /**
01777  * Set the gid to use when you set the replace_gid to 2.
01778  *
01779  * @see iso_write_opts_set_replace_mode
01780  * @since 0.6.2
01781  */
01782 int iso_write_opts_set_default_gid(IsoWriteOpts *opts, gid_t gid);
01783 
01784 /**
01785  * 0 to use IsoNode timestamps, 1 to use recording time, 2 to use
01786  * values from timestamp field. This has only meaning if RR extensions
01787  * are enabled.
01788  *
01789  * @see iso_write_opts_set_default_timestamp
01790  * @since 0.6.2
01791  */
01792 int iso_write_opts_set_replace_timestamps(IsoWriteOpts *opts, int replace);
01793 
01794 /**
01795  * Set the timestamp to use when you set the replace_timestamps to 2.
01796  *
01797  * @see iso_write_opts_set_replace_timestamps
01798  * @since 0.6.2
01799  */
01800 int iso_write_opts_set_default_timestamp(IsoWriteOpts *opts, time_t timestamp);
01801 
01802 /**
01803  * Whether to always record timestamps in GMT.
01804  *
01805  * By default, libisofs stores local time information on image. You can set
01806  * this to always store timestamps converted to GMT. This prevents any
01807  * discrimination of the timezone of the image preparer by the image reader.
01808  *
01809  * It is useful if you want to hide your timezone, or you live in a timezone
01810  * that can't be represented in ECMA-119. These are timezones with an offset
01811  * from GMT greater than +13 hours, lower than -12 hours, or not a multiple
01812  * of 15 minutes.
01813  * Negative timezones (west of GMT) can trigger bugs in some operating systems
01814  * which typically appear in mounted ISO images as if the timezone shift from
01815  * GMT was applied twice (e.g. in New York 22:36 becomes 17:36).
01816  *
01817  * @since 0.6.2
01818  */
01819 int iso_write_opts_set_always_gmt(IsoWriteOpts *opts, int gmt);
01820 
01821 /**
01822  * Set the charset to use for the RR names of the files that will be created
01823  * on the image.
01824  * NULL to use default charset, that is the locale charset.
01825  * You can obtain the list of charsets supported on your system executing
01826  * "iconv -l" in a shell.
01827  *
01828  * @since 0.6.2
01829  */
01830 int iso_write_opts_set_output_charset(IsoWriteOpts *opts, const char *charset);
01831 
01832 /**
01833  * Set the type of image creation in case there was already an existing
01834  * image imported. Libisofs supports two types of creation:
01835  * stand-alone and appended.
01836  *
01837  * A stand-alone image is an image that does not need the old image any more
01838  * for being mounted by the operating system or imported by libisofs. It may
01839  * be written beginning with byte 0 of optical media or disk file objects. 
01840  * There will be no distinction between files from the old image and those
01841  * which have been added by the new image generation.
01842  *
01843  * On the other side, an appended image is not self contained. It may refer
01844  * to files that stay stored in the imported existing image.
01845  * This usage model is inspired by CD multi-session. It demands that the
01846  * appended image is finally written to the same media resp. disk file
01847  * as the imported image at an address behind the end of that imported image.
01848  * The exact address may depend on media peculiarities and thus has to be
01849  * announced by the application via iso_write_opts_set_ms_block().
01850  * The real address where the data will be written is under control of the
01851  * consumer of the struct burn_source which takes the output of libisofs
01852  * image generation. It may be the one announced to libisofs or an intermediate
01853  * one. Nevertheless, the image will be readable only at the announced address.
01854  *
01855  * If you have not imported a previous image by iso_image_import(), then the
01856  * image will always be a stand-alone image, as there is no previous data to
01857  * refer to. 
01858  *
01859  * @param opts
01860  *      The option set to be manipulated.
01861  * @param append
01862  *      1 to create an appended image, 0 for an stand-alone one.
01863  *
01864  * @since 0.6.2
01865  */
01866 int iso_write_opts_set_appendable(IsoWriteOpts *opts, int append);
01867 
01868 /**
01869  * Set the start block of the image. It is supposed to be the lba where the
01870  * first block of the image will be written on disc. All references inside the
01871  * ISO image will take this into account, thus providing a mountable image.
01872  *
01873  * For appendable images, that are written to a new session, you should
01874  * pass here the lba of the next writable address on disc.
01875  *
01876  * In stand alone images this is usually 0. However, you may want to
01877  * provide a different ms_block if you don't plan to burn the image in the
01878  * first session on disc, such as in some CD-Extra disc whether the data
01879  * image is written in a new session after some audio tracks.
01880  *
01881  * @since 0.6.2
01882  */
01883 int iso_write_opts_set_ms_block(IsoWriteOpts *opts, uint32_t ms_block);
01884 
01885 /**
01886  * Sets the buffer where to store the descriptors which shall be written
01887  * at the beginning of an overwriteable media to point to the newly written
01888  * image.
01889  * This is needed if the write start address of the image is not 0.
01890  * In this case the first 64 KiB of the media have to be overwritten
01891  * by the buffer content after the session was written and the buffer
01892  * was updated by libisofs. Otherwise the new session would not be
01893  * found by operating system function mount() or by libisoburn.
01894  * (One could still mount that session if its start address is known.)
01895  *
01896  * If you do not need this information, for example because you are creating a
01897  * new image for LBA 0 or because you will create an image for a true
01898  * multisession media, just do not use this call or set buffer to NULL.
01899  *
01900  * Use cases:
01901  *
01902  * - Together with iso_write_opts_set_appendable(opts, 1) the buffer serves
01903  *   for the growing of an image as done in growisofs by Andy Polyakov.
01904  *   This allows appending of a new session to non-multisession media, such
01905  *   as DVD+RW. The new session will refer to the data of previous sessions
01906  *   on the same media.
01907  *   libisoburn emulates multisession appendability on overwriteable media
01908  *   and disk files by performing this use case.
01909  *
01910  * - Together with iso_write_opts_set_appendable(opts, 0) the buffer allows
01911  *   to write the first session on overwriteable media to start addresses
01912  *   other than 0.
01913  *   This address must not be smaller than 32 blocks plus the eventual
01914  *   partition offset as defined by iso_write_opts_set_part_offset().
01915  *   libisoburn in most cases writes the first session on overwriteable media
01916  *   and disk files to LBA (32 + partition_offset) in order to preserve its
01917  *   descriptors from the subsequent overwriting by the descriptor buffer of
01918  *   later sessions.
01919  *
01920  * @param opts
01921  *      The option set to be manipulated.
01922  * @param overwrite
01923  *      When not NULL, it should point to at least 64KiB of memory, where
01924  *      libisofs will install the contents that shall be written at the
01925  *      beginning of overwriteable media.
01926  *      You should initialize the buffer either with 0s, or with the contents
01927  *      of the first 32 blocks of the image you are growing. In most cases,
01928  *      0 is good enought.
01929  *      IMPORTANT: If you use iso_write_opts_set_part_offset() then the
01930  *                 overwrite buffer must be larger by the offset defined there.
01931  *
01932  * @since 0.6.2
01933  */
01934 int iso_write_opts_set_overwrite_buf(IsoWriteOpts *opts, uint8_t *overwrite);
01935 
01936 /**
01937  * Set the size, in number of blocks, of the ring buffer used between the
01938  * writer thread and the burn_source. You have to provide at least a 32
01939  * blocks buffer. Default value is set to 2MB, if that is ok for you, you
01940  * don't need to call this function.
01941  *
01942  * @since 0.6.2
01943  */
01944 int iso_write_opts_set_fifo_size(IsoWriteOpts *opts, size_t fifo_size);
01945 
01946 /*
01947  * Attach 32 kB of binary data which shall get written to the first 32 kB 
01948  * of the ISO image, the ECMA-119 System Area. This space is intended for
01949  * system dependent boot software, e.g. a Master Boot Record which allows to
01950  * boot from USB sticks or hard disks. ECMA-119 makes no own assumptions or
01951  * prescriptions about the byte content.
01952  *
01953  * If system area data are given or options bit0 is set, then bit1 of
01954  * el_torito_set_isolinux_options() is automatically disabled.
01955  *
01956  * @param opts
01957  *      The option set to be manipulated.
01958  * @param data
01959  *        Either NULL or 32 kB of data. Do not submit less bytes !
01960  * @param options
01961  *        Can cause manipulations of submitted data before they get written:
01962  *        bit0= Only with System area type 0 = MBR
01963  *              Apply a --protective-msdos-label as of grub-mkisofs.
01964  *              This means to patch bytes 446 to 512 of the system area so
01965  *              that one partition is defined which begins at the second
01966  *              512-byte block of the image and ends where the image ends.
01967  *              This works with and without system_area_data.
01968  *        bit1= Only with System area type 0 = MBR
01969  *              Apply isohybrid MBR patching to the system area.
01970  *              This works only with system area data from SYSLINUX plus an
01971  *              ISOLINUX boot image (see iso_image_set_boot_image()) and
01972  *              only if not bit0 is set.
01973  *        bit2-7= System area type
01974  *              0= with bit0 or bit1: MBR
01975  *                 else: unspecified type which will be used unaltered.
01976  *              @since 0.6.38
01977  *              1= MIPS Big Endian Volume Header
01978  *                 Submit up to 15 MIPS Big Endian boot files by
01979  *                 iso_image_add_mips_boot_file().
01980  *                 This will overwrite the first 512 bytes of the submitted
01981  *                 data.
01982  *              2= DEC Boot Block for MIPS Little Endian
01983  *                 The first boot file submitted by
01984  *                 iso_image_add_mips_boot_file() will be activated.
01985  *                 This will overwrite the first 512 bytes of the submitted
01986  *                 data.
01987  *              @since 0.6.40
01988  *              3= SUN Disk Label for SUN SPARC
01989  *                 Submit up to 7 SPARC boot images by
01990  *                 iso_write_opts_set_partition_img() for partition numbers 2
01991  *                 to 8.
01992  *                 This will overwrite the first 512 bytes of the submitted
01993  *        bit8-9= Only with System area type 0 = MBR
01994  *                @since 1.0.4
01995  *                Cylinder alignment mode eventually pads the image to make it
01996  *                end at a cylinder boundary.
01997  *                0 = auto (align if bit1)
01998  *                1 = always align to cylinder boundary
01999  *                2 = never align to cylinder boundary
02000  * @param flag
02001  *        bit0 = invalidate any attached system area data. Same as data == NULL
02002  *               (This re-activates eventually loaded image System Area data.
02003  *                To erase those, submit 32 kB of zeros without flag bit0.)
02004  *        bit1 = keep data unaltered
02005  *        bit2 = keep options unaltered
02006  * @return
02007  *      ISO_SUCCESS or error
02008  * @since 0.6.30
02009  */
02010 int iso_write_opts_set_system_area(IsoWriteOpts *opts, char data[32768],
02011                                    int options, int flag);
02012 
02013 /**
02014  * Set a name for the system area. This setting is ignored unless system area
02015  * type 3 "SUN Disk Label" is in effect by iso_write_opts_set_system_area().
02016  * In this case it will replace the default text at the start of the image:
02017  *   "CD-ROM Disc with Sun sparc boot created by libisofs"
02018  *
02019  * @param opts
02020  *      The option set to be manipulated.
02021  * @param label
02022  *      A text of up to 128 characters.
02023  * @return
02024  *      ISO_SUCCESS or error
02025  * @since 0.6.40
02026 */
02027 int iso_write_opts_set_disc_label(IsoWriteOpts *opts, char *label);
02028 
02029 /**
02030  * Explicitely set the four timestamps of the emerging Primary Volume
02031  * Descriptor. Default with all parameters is 0.
02032  * ECMA-119 defines them as:
02033  * @param opts
02034  *        The option set to be manipulated.
02035  * @param vol_creation_time
02036  *        When "the information in the volume was created."
02037  *        A value of 0 means that the timepoint of write start is to be used.
02038  * @param vol_modification_time
02039  *        When "the information in the volume was last modified."
02040  *        A value of 0 means that the timepoint of write start is to be used.
02041  * @param vol_expiration_time
02042  *        When "the information in the volume may be regarded as obsolete."
02043  *        A value of 0 means that the information never shall expire.
02044  * @param vol_effective_time
02045  *        When "the information in the volume may be used."
02046  *        A value of 0 means that not such retention is intended.
02047  * @param vol_uuid
02048  *        If this text is not empty, then it overrides vol_creation_time and
02049  *        vol_modification_time by copying the first 16 decimal digits from
02050  *        uuid, eventually padding up with decimal '1', and writing a NUL-byte
02051  *        as timezone.
02052  *        Other than with vol_*_time the resulting string in the ISO image
02053  *        is fully predictable and free of timezone pitfalls.
02054  *        It should express a reasonable time in form  YYYYMMDDhhmmsscc
02055  *        E.g.:  "2010040711405800" = 7 Apr 2010 11:40:58 (+0 centiseconds)
02056  * @return
02057  *        ISO_SUCCESS or error
02058  *
02059  * @since 0.6.30
02060  */
02061 int iso_write_opts_set_pvd_times(IsoWriteOpts *opts,
02062                         time_t vol_creation_time, time_t vol_modification_time,
02063                         time_t vol_expiration_time, time_t vol_effective_time,
02064                         char *vol_uuid);
02065 
02066 
02067 /*
02068  * Control production of a second set of volume descriptors (superblock)
02069  * and directory trees, together with a partition table in the MBR where the
02070  * first partition has non-zero start address and the others are zeroed.
02071  * The first partition stretches to the end of the whole ISO image.
02072  * The additional volume descriptor set and trees will allow to mount the
02073  * ISO image at the start of the first partition, while it is still possible
02074  * to mount it via the normal first volume descriptor set and tree at the
02075  * start of the image resp. storage device.
02076  * This makes few sense on optical media. But on USB sticks it creates a
02077  * conventional partition table which makes it mountable on e.g. Linux via
02078  * /dev/sdb and /dev/sdb1 alike.
02079  * IMPORTANT: When submitting memory by iso_write_opts_set_overwrite_buf()
02080  *            then its size must be at least 64 KiB + partition offset. 
02081  *
02082  * @param opts
02083  *        The option set to be manipulated.
02084  * @param block_offset_2k
02085  *        The offset of the partition start relative to device start.
02086  *        This is counted in 2 kB blocks. The partition table will show the
02087  *        according number of 512 byte sectors.
02088  *        Default is 0 which causes no special partition table preparations.
02089  *        If it is not 0 then it must not be smaller than 16.
02090  * @param secs_512_per_head
02091  *        Number of 512 byte sectors per head. 1 to 63. 0=automatic.
02092  * @param heads_per_cyl
02093  *        Number of heads per cylinder. 1 to 255. 0=automatic.
02094  * @return
02095  *        ISO_SUCCESS or error
02096  *
02097  * @since 0.6.36
02098  */
02099 int iso_write_opts_set_part_offset(IsoWriteOpts *opts,
02100                                    uint32_t block_offset_2k,
02101                                    int secs_512_per_head, int heads_per_cyl);
02102 
02103 
02104 /** The minimum version of libjte to be used with this version of libisofs
02105     at compile time. The use of libjte is optional and depends on configure
02106     tests. It can be prevented by ./configure option --disable-libjte .
02107     @since 0.6.38
02108 */
02109 #define iso_libjte_req_major 1
02110 #define iso_libjte_req_minor 0
02111 #define iso_libjte_req_micro 0
02112 
02113 /** 
02114  * Associate a libjte environment object to the upcomming write run.
02115  * libjte implements Jigdo Template Extraction as of Steve McIntyre and
02116  * Richard Atterer.
02117  * The call will fail if no libjte support was enabled at compile time.
02118  * @param opts
02119  *        The option set to be manipulated.
02120  * @param libjte_handle
02121  *        Pointer to a struct libjte_env e.g. created by libjte_new().
02122  *        It must stay existent from the start of image generation by
02123  *        iso_image_create_burn_source() until the write thread has ended.
02124  *        This can be inquired by iso_image_generator_is_running().
02125  *        In order to keep the libisofs API identical with and without
02126  *        libjte support the parameter type is (void *).
02127  * @return
02128  *        ISO_SUCCESS or error
02129  *
02130  * @since 0.6.38
02131 */
02132 int iso_write_opts_attach_jte(IsoWriteOpts *opts, void *libjte_handle);
02133 
02134 /**
02135  * Remove eventual association to a libjte environment handle.
02136  * The call will fail if no libjte support was enabled at compile time.
02137  * @param opts
02138  *        The option set to be manipulated.
02139  * @param libjte_handle
02140  *        If not submitted as NULL, this will return the previously set
02141  *        libjte handle. 
02142  * @return
02143  *        ISO_SUCCESS or error
02144  *
02145  * @since 0.6.38
02146 */
02147 int iso_write_opts_detach_jte(IsoWriteOpts *opts, void **libjte_handle);
02148 
02149 
02150 /**
02151  * Cause a number of blocks with zero bytes to be written after the payload
02152  * data, but before the eventual checksum data. Unlike libburn tail padding,
02153  * these blocks are counted as part of the image and covered by eventual
02154  * image checksums.
02155  * A reason for such padding can be the wish to prevent the Linux read-ahead
02156  * bug by sacrificial data which still belong to image and Jigdo template.
02157  * Normally such padding would be the job of the burn program which should know
02158  * that it is needed with CD write type TAO if Linux read(2) shall be able
02159  * to read all payload blocks.
02160  * 150 blocks = 300 kB is the traditional sacrifice to the Linux kernel.
02161  * @param opts
02162  *        The option set to be manipulated.
02163  * @param num_blocks
02164  *        Number of extra 2 kB blocks to be written.
02165  * @return
02166  *        ISO_SUCCESS or error
02167  *
02168  * @since 0.6.38
02169  */
02170 int iso_write_opts_set_tail_blocks(IsoWriteOpts *opts, uint32_t num_blocks);
02171 
02172 
02173 /**
02174  * Cause an arbitrary data file to be appended to the ISO image and to be
02175  * described by a partition table entry in an MBR or SUN Disk Label at the
02176  * start of the ISO image.
02177  * The partition entry will bear the size of the image file rounded up to
02178  * the next multiple of 2048 bytes.
02179  * MBR or SUN Disk Label are selected by iso_write_opts_set_system_area()
02180  * system area type: 0 selects MBR partition table. 3 selects a SUN partition
02181  * table with 320 kB start alignment.
02182  *
02183  * @param opts
02184  *        The option set to be manipulated.
02185  * @param partition_number
02186  *        Depicts the partition table entry which shall describe the
02187  *        appended image.
02188  *        Range with MBR: 1 to 4. 1 will cause the whole ISO image to be
02189  *                        unclaimable space before partition 1.
02190  *        Range with SUN Disk Label: 2 to 8.
02191  * @param image_path
02192  *        File address in the local file system.
02193  *        With SUN Disk Label: an empty name causes the partition to become
02194  *        a copy of the next lower partition.
02195  * @param image_type
02196  *        The MBR partition type. E.g. FAT12 = 0x01 , FAT16 = 0x06, 
02197  *        Linux Native Partition = 0x83. See fdisk command L.
02198  *        This parameter is ignored with SUN Disk Label.
02199  * @return
02200  *        ISO_SUCCESS or error
02201  *
02202  * @since 0.6.38
02203  */
02204 int iso_write_opts_set_partition_img(IsoWriteOpts *opts, int partition_number,
02205                            uint8_t partition_type, char *image_path, int flag);
02206 
02207 
02208 /**
02209  * Inquire the start address of the file data blocks after having used
02210  * IsoWriteOpts with iso_image_create_burn_source().
02211  * @param opts
02212  *        The option set that was used when starting image creation
02213  * @param data_start
02214  *        Returns the logical block address if it is already valid
02215  * @param flag
02216  *        Reserved for future usage, set to 0.
02217  * @return
02218  *        1 indicates valid data_start, <0 indicates invalid data_start
02219  *
02220  * @since 0.6.16
02221  */
02222 int iso_write_opts_get_data_start(IsoWriteOpts *opts, uint32_t *data_start,
02223                                   int flag);
02224 
02225 /**
02226  * Update the sizes of all files added to image.
02227  *
02228  * This may be called just before iso_image_create_burn_source() to force
02229  * libisofs to check the file sizes again (they're already checked when added
02230  * to IsoImage). It is useful if you have changed some files after adding then
02231  * to the image.
02232  *
02233  * @return
02234  *    1 on success, < 0 on error
02235  * @since 0.6.8
02236  */
02237 int iso_image_update_sizes(IsoImage *image);
02238 
02239 /**
02240  * Create a burn_source and a thread which immediately begins to generate
02241  * the image. That burn_source can be used with libburn as a data source
02242  * for a track. A copy of its public declaration in libburn.h can be found
02243  * further below in this text.
02244  *
02245  * If image generation shall be aborted by the application program, then
02246  * the .cancel() method of the burn_source must be called to end the
02247  * generation thread:  burn_src->cancel(burn_src);
02248  *
02249  * @param image
02250  *     The image to write.
02251  * @param opts
02252  *     The options for image generation. All needed data will be copied, so
02253  *     you can free the given struct once this function returns.
02254  * @param burn_src
02255  *     Location where the pointer to the burn_source will be stored
02256  * @return
02257  *     1 on success, < 0 on error
02258  *
02259  * @since 0.6.2
02260  */
02261 int iso_image_create_burn_source(IsoImage *image, IsoWriteOpts *opts,
02262                                  struct burn_source **burn_src);
02263 
02264 /**
02265  * Inquire whether the image generator thread is still at work. As soon as the
02266  * reply is 0, the caller of iso_image_create_burn_source() may assume that
02267  * the image generation has ended.
02268  * Nevertheless there may still be readily formatted output data pending in
02269  * the burn_source or its consumers. So the final delivery of the image has
02270  * also to be checked at the data consumer side,e.g. by burn_drive_get_status()
02271  * in case of libburn as consumer.
02272  * @param image
02273  *     The image to inquire.
02274  * @return
02275  *     1 generating of image stream is still in progress
02276  *     0 generating of image stream has ended meanwhile
02277  *
02278  * @since 0.6.38
02279  */
02280 int iso_image_generator_is_running(IsoImage *image);
02281 
02282 /**
02283  * Creates an IsoReadOpts for reading an existent image. You should set the
02284  * options desired with the correspondent setters. Note that you may want to
02285  * set the start block value.
02286  *
02287  * Options by default are determined by the selected profile.
02288  *
02289  * @param opts
02290  *     Pointer to the location where the newly created IsoReadOpts will be
02291  *     stored. You should free it with iso_read_opts_free() when no more
02292  *     needed.
02293  * @param profile
02294  *     Default profile for image reading. For now the following values are
02295  *     defined:
02296  *     ---> 0 [STANDARD]
02297  *         Suitable for most situations. Most extension are read. When both
02298  *         Joliet and RR extension are present, RR is used.
02299  *         AAIP for ACL and xattr is not enabled by default.
02300  * @return
02301  *      1 success, < 0 error
02302  *
02303  * @since 0.6.2
02304  */
02305 int iso_read_opts_new(IsoReadOpts **opts, int profile);
02306 
02307 /**
02308  * Free an IsoReadOpts previously allocated with iso_read_opts_new().
02309  *
02310  * @since 0.6.2
02311  */
02312 void iso_read_opts_free(IsoReadOpts *opts);
02313 
02314 /**
02315  * Set the block where the image begins. It is usually 0, but may be different
02316  * on a multisession disc.
02317  *
02318  * @since 0.6.2
02319  */
02320 int iso_read_opts_set_start_block(IsoReadOpts *opts, uint32_t block);
02321 
02322 /**
02323  * Do not read Rock Ridge extensions.
02324  * In most cases you don't want to use this. It could be useful if RR info
02325  * is damaged, or if you want to use the Joliet tree.
02326  *
02327  * @since 0.6.2
02328  */
02329 int iso_read_opts_set_no_rockridge(IsoReadOpts *opts, int norr);
02330 
02331 /**
02332  * Do not read Joliet extensions.
02333  *
02334  * @since 0.6.2
02335  */
02336 int iso_read_opts_set_no_joliet(IsoReadOpts *opts, int nojoliet);
02337 
02338 /**
02339  * Do not read ISO 9660:1999 enhanced tree
02340  *
02341  * @since 0.6.2
02342  */
02343 int iso_read_opts_set_no_iso1999(IsoReadOpts *opts, int noiso1999);
02344 
02345 /**
02346  * Control reading of AAIP informations about ACL and xattr when loading
02347  * existing images.
02348  * For importing ACL and xattr when inserting nodes from external filesystems
02349  * (e.g. the local POSIX filesystem) see iso_image_set_ignore_aclea().
02350  * For eventual writing of this information see iso_write_opts_set_aaip().
02351  *
02352  * @param opts
02353  *       The option set to be manipulated
02354  * @param noaaip
02355  *       1 = Do not read AAIP information
02356  *       0 = Read AAIP information if available
02357  *       All other values are reserved.
02358  * @since 0.6.14
02359  */
02360 int iso_read_opts_set_no_aaip(IsoReadOpts *opts, int noaaip);
02361 
02362 /**
02363  * Control reading of an array of MD5 checksums which is eventually stored
02364  * at the end of a session. See also iso_write_opts_set_record_md5().
02365  * Important: Loading of the MD5 array will only work if AAIP is enabled
02366  *            because its position and layout is recorded in xattr "isofs.ca".
02367  *
02368  * @param opts
02369  *       The option set to be manipulated
02370  * @param no_md5
02371  *       0 = Read MD5 array if available, refuse on non-matching MD5 tags
02372  *       1 = Do not read MD5 checksum array
02373  *       2 = Read MD5 array, but do not check MD5 tags
02374  *           @since 1.0.4
02375  *       All other values are reserved.
02376  *
02377  * @since 0.6.22
02378  */
02379 int iso_read_opts_set_no_md5(IsoReadOpts *opts, int no_md5);
02380 
02381 
02382 /**
02383  * Control discarding of eventual inode numbers from existing images.
02384  * Such numbers may come from RRIP 1.12 entries PX. If not discarded they
02385  * get written unchanged when the file object gets written into an ISO image. 
02386  * If this inode number is missing with a file in the imported image,
02387  * or if it has been discarded during image reading, then a unique inode number
02388  * will be generated at some time before the file gets written into an ISO
02389  * image.
02390  * Two image nodes which have the same inode number represent two hardlinks
02391  * of the same file object. So discarding the numbers splits hardlinks.
02392  *
02393  * @param opts
02394  *       The option set to be manipulated
02395  * @param new_inos
02396  *     1 = Discard imported inode numbers and finally hand out a unique new
02397  *         one to each single file before it gets written into an ISO image.
02398  *     0 = Keep eventual inode numbers from PX entries.
02399  *         All other values are reserved.
02400  * @since 0.6.20
02401  */
02402 int iso_read_opts_set_new_inos(IsoReadOpts *opts, int new_inos);
02403 
02404 /**
02405  * Whether to prefer Joliet over RR. libisofs usually prefers RR over
02406  * Joliet, as it give us much more info about files. So, if both extensions
02407  * are present, RR is used. You can set this if you prefer Joliet, but
02408  * note that this is not very recommended. This doesn't mean than RR
02409  * extensions are not read: if no Joliet is present, libisofs will read
02410  * RR tree.
02411  *
02412  * @since 0.6.2
02413  */
02414 int iso_read_opts_set_preferjoliet(IsoReadOpts *opts, int preferjoliet);
02415 
02416 /**
02417  * Set default uid for files when RR extensions are not present.
02418  *
02419  * @since 0.6.2
02420  */
02421 int iso_read_opts_set_default_uid(IsoReadOpts *opts, uid_t uid);
02422 
02423 /**
02424  * Set default gid for files when RR extensions are not present.
02425  *
02426  * @since 0.6.2
02427  */
02428 int iso_read_opts_set_default_gid(IsoReadOpts *opts, gid_t gid);
02429 
02430 /**
02431  * Set default permissions for files when RR extensions are not present.
02432  *
02433  * @param opts
02434  *       The option set to be manipulated
02435  * @param file_perm
02436  *      Permissions for files.
02437  * @param dir_perm
02438  *      Permissions for directories.
02439  *
02440  * @since 0.6.2
02441  */
02442 int iso_read_opts_set_default_permissions(IsoReadOpts *opts, mode_t file_perm,
02443                                           mode_t dir_perm);
02444 
02445 /**
02446  * Set the input charset of the file names on the image. NULL to use locale
02447  * charset. You have to specify a charset if the image filenames are encoded
02448  * in a charset different that the local one. This could happen, for example,
02449  * if the image was created on a system with different charset.
02450  *
02451  * @param opts
02452  *       The option set to be manipulated
02453  * @param charset
02454  *      The charset to use as input charset.  You can obtain the list of
02455  *      charsets supported on your system executing "iconv -l" in a shell.
02456  *
02457  * @since 0.6.2
02458  */
02459 int iso_read_opts_set_input_charset(IsoReadOpts *opts, const char *charset);
02460 
02461 /**
02462  * Enable or disable methods to automatically choose an input charset.
02463  * This eventually overrides the name set via iso_read_opts_set_input_charset()
02464  *
02465  * @param opts
02466  *       The option set to be manipulated
02467  * @param mode
02468  *       Bitfield for control purposes:
02469  *       bit0= Allow to use the input character set name which is eventually
02470  *             stored in attribute "isofs.cs" of the root directory.
02471  *             Applications may attach this xattr by iso_node_set_attrs() to
02472  *             the root node, call iso_write_opts_set_output_charset() with the
02473  *             same name and enable iso_write_opts_set_aaip() when writing
02474  *             an image.
02475  *       Submit any other bits with value 0.
02476  *
02477  * @since 0.6.18
02478  *
02479  */
02480 int iso_read_opts_auto_input_charset(IsoReadOpts *opts, int mode);
02481 
02482 /**
02483  * Enable or disable loading of the first 32768 bytes of the session.
02484  *
02485  * @param opts
02486  *       The option set to be manipulated
02487  * @param mode
02488  *       Bitfield for control purposes:
02489  *       bit0= Load System Area data and attach them to the image so that they
02490  *             get written by the next session, if not overridden by
02491  *             iso_write_opts_set_system_area().
02492  *       Submit any other bits with value 0.
02493  *
02494  * @since 0.6.30
02495  *
02496  */
02497 int iso_read_opts_load_system_area(IsoReadOpts *opts, int mode);
02498 
02499 /**
02500  * Import a previous session or image, for growing or modify.
02501  *
02502  * @param image
02503  *     The image context to which old image will be imported. Note that all
02504  *     files added to image, and image attributes, will be replaced with the
02505  *     contents of the old image.
02506  *     TODO #00025 support for merging old image files
02507  * @param src
02508  *     Data Source from which old image will be read. A extra reference is
02509  *     added, so you still need to iso_data_source_unref() yours.
02510  * @param opts
02511  *     Options for image import. All needed data will be copied, so you
02512  *     can free the given struct once this function returns.
02513  * @param features
02514  *     If not NULL, a new IsoReadImageFeatures will be allocated and filled
02515  *     with the features of the old image. It should be freed with
02516  *     iso_read_image_features_destroy() when no more needed. You can pass
02517  *     NULL if you're not interested on them.
02518  * @return
02519  *     1 on success, < 0 on error
02520  *
02521  * @since 0.6.2
02522  */
02523 int iso_image_import(IsoImage *image, IsoDataSource *src, IsoReadOpts *opts,
02524                      IsoReadImageFeatures **features);
02525 
02526 /**
02527  * Destroy an IsoReadImageFeatures object obtained with iso_image_import.
02528  *
02529  * @since 0.6.2
02530  */
02531 void iso_read_image_features_destroy(IsoReadImageFeatures *f);
02532 
02533 /**
02534  * Get the size (in 2048 byte block) of the image, as reported in the PVM.
02535  *
02536  * @since 0.6.2
02537  */
02538 uint32_t iso_read_image_features_get_size(IsoReadImageFeatures *f);
02539 
02540 /**
02541  * Whether RockRidge extensions are present in the image imported.
02542  *
02543  * @since 0.6.2
02544  */
02545 int iso_read_image_features_has_rockridge(IsoReadImageFeatures *f);
02546 
02547 /**
02548  * Whether Joliet extensions are present in the image imported.
02549  *
02550  * @since 0.6.2
02551  */
02552 int iso_read_image_features_has_joliet(IsoReadImageFeatures *f);
02553 
02554 /**
02555  * Whether the image is recorded according to ISO 9660:1999, i.e. it has
02556  * a version 2 Enhanced Volume Descriptor.
02557  *
02558  * @since 0.6.2
02559  */
02560 int iso_read_image_features_has_iso1999(IsoReadImageFeatures *f);
02561 
02562 /**
02563  * Whether El-Torito boot record is present present in the image imported.
02564  *
02565  * @since 0.6.2
02566  */
02567 int iso_read_image_features_has_eltorito(IsoReadImageFeatures *f);
02568 
02569 /**
02570  * Increments the reference counting of the given image.
02571  *
02572  * @since 0.6.2
02573  */
02574 void iso_image_ref(IsoImage *image);
02575 
02576 /**
02577  * Decrements the reference couting of the given image.
02578  * If it reaches 0, the image is free, together with its tree nodes (whether
02579  * their refcount reach 0 too, of course).
02580  *
02581  * @since 0.6.2
02582  */
02583 void iso_image_unref(IsoImage *image);
02584 
02585 /**
02586  * Attach user defined data to the image. Use this if your application needs
02587  * to store addition info together with the IsoImage. If the image already
02588  * has data attached, the old data will be freed.
02589  *
02590  * @param image
02591  *      The image to which data shall be attached.
02592  * @param data
02593  *      Pointer to application defined data that will be attached to the
02594  *      image. You can pass NULL to remove any already attached data.
02595  * @param give_up
02596  *      Function that will be called when the image does not need the data
02597  *      any more. It receives the data pointer as an argumente, and eventually
02598  *      causes data to be freed. It can be NULL if you don't need it.
02599  * @return
02600  *      1 on succes, < 0 on error
02601  *
02602  * @since 0.6.2
02603  */
02604 int iso_image_attach_data(IsoImage *image, void *data, void (*give_up)(void*));
02605 
02606 /**
02607  * The the data previously attached with iso_image_attach_data()
02608  *
02609  * @since 0.6.2
02610  */
02611 void *iso_image_get_attached_data(IsoImage *image);
02612 
02613 /**
02614  * Get the root directory of the image.
02615  * No extra ref is added to it, so you musn't unref it. Use iso_node_ref()
02616  * if you want to get your own reference.
02617  *
02618  * @since 0.6.2
02619  */
02620 IsoDir *iso_image_get_root(const IsoImage *image);
02621 
02622 /**
02623  * Fill in the volset identifier for a image.
02624  *
02625  * @since 0.6.2
02626  */
02627 void iso_image_set_volset_id(IsoImage *image, const char *volset_id);
02628 
02629 /**
02630  * Get the volset identifier.
02631  * The returned string is owned by the image and should not be freed nor
02632  * changed.
02633  *
02634  * @since 0.6.2
02635  */
02636 const char *iso_image_get_volset_id(const IsoImage *image);
02637 
02638 /**
02639  * Fill in the volume identifier for a image.
02640  *
02641  * @since 0.6.2
02642  */
02643 void iso_image_set_volume_id(IsoImage *image, const char *volume_id);
02644 
02645 /**
02646  * Get the volume identifier.
02647  * The returned string is owned by the image and should not be freed nor
02648  * changed.
02649  *
02650  * @since 0.6.2
02651  */
02652 const char *iso_image_get_volume_id(const IsoImage *image);
02653 
02654 /**
02655  * Fill in the publisher for a image.
02656  *
02657  * @since 0.6.2
02658  */
02659 void iso_image_set_publisher_id(IsoImage *image, const char *publisher_id);
02660 
02661 /**
02662  * Get the publisher of a image.
02663  * The returned string is owned by the image and should not be freed nor
02664  * changed.
02665  *
02666  * @since 0.6.2
02667  */
02668 const char *iso_image_get_publisher_id(const IsoImage *image);
02669 
02670 /**
02671  * Fill in the data preparer for a image.
02672  *
02673  * @since 0.6.2
02674  */
02675 void iso_image_set_data_preparer_id(IsoImage *image,
02676                                     const char *data_preparer_id);
02677 
02678 /**
02679  * Get the data preparer of a image.
02680  * The returned string is owned by the image and should not be freed nor
02681  * changed.
02682  *
02683  * @since 0.6.2
02684  */
02685 const char *iso_image_get_data_preparer_id(const IsoImage *image);
02686 
02687 /**
02688  * Fill in the system id for a image. Up to 32 characters.
02689  *
02690  * @since 0.6.2
02691  */
02692 void iso_image_set_system_id(IsoImage *image, const char *system_id);
02693 
02694 /**
02695  * Get the system id of a image.
02696  * The returned string is owned by the image and should not be freed nor
02697  * changed.
02698  *
02699  * @since 0.6.2
02700  */
02701 const char *iso_image_get_system_id(const IsoImage *image);
02702 
02703 /**
02704  * Fill in the application id for a image. Up to 128 chars.
02705  *
02706  * @since 0.6.2
02707  */
02708 void iso_image_set_application_id(IsoImage *image, const char *application_id);
02709 
02710 /**
02711  * Get the application id of a image.
02712  * The returned string is owned by the image and should not be freed nor
02713  * changed.
02714  *
02715  * @since 0.6.2
02716  */
02717 const char *iso_image_get_application_id(const IsoImage *image);
02718 
02719 /**
02720  * Fill copyright information for the image. Usually this refers
02721  * to a file on disc. Up to 37 characters.
02722  *
02723  * @since 0.6.2
02724  */
02725 void iso_image_set_copyright_file_id(IsoImage *image,
02726                                      const char *copyright_file_id);
02727 
02728 /**
02729  * Get the copyright information of a image.
02730  * The returned string is owned by the image and should not be freed nor
02731  * changed.
02732  *
02733  * @since 0.6.2
02734  */
02735 const char *iso_image_get_copyright_file_id(const IsoImage *image);
02736 
02737 /**
02738  * Fill abstract information for the image. Usually this refers
02739  * to a file on disc. Up to 37 characters.
02740  *
02741  * @since 0.6.2
02742  */
02743 void iso_image_set_abstract_file_id(IsoImage *image,
02744                                     const char *abstract_file_id);
02745 
02746 /**
02747  * Get the abstract information of a image.
02748  * The returned string is owned by the image and should not be freed nor
02749  * changed.
02750  *
02751  * @since 0.6.2
02752  */
02753 const char *iso_image_get_abstract_file_id(const IsoImage *image);
02754 
02755 /**
02756  * Fill biblio information for the image. Usually this refers
02757  * to a file on disc. Up to 37 characters.
02758  *
02759  * @since 0.6.2
02760  */
02761 void iso_image_set_biblio_file_id(IsoImage *image, const char *biblio_file_id);
02762 
02763 /**
02764  * Get the biblio information of a image.
02765  * The returned string is owned by the image and should not be freed nor
02766  * changed.
02767  *
02768  * @since 0.6.2
02769  */
02770 const char *iso_image_get_biblio_file_id(const IsoImage *image);
02771 
02772 /**
02773  * Create a new set of El-Torito bootable images by adding a boot catalog
02774  * and the default boot image.
02775  * Further boot images may then be added by iso_image_add_boot_image().
02776  *
02777  * @param image
02778  *      The image to make bootable. If it was already bootable this function
02779  *      returns an error and the image remains unmodified.
02780  * @param image_path
02781  *      The absolute path of a IsoFile to be used as default boot image.
02782  * @param type
02783  *      The boot media type. This can be one of 3 types:
02784  *             - Floppy emulation: Boot image file must be exactly
02785  *               1200 kB, 1440 kB or 2880 kB.
02786  *             - Hard disc emulation: The image must begin with a master
02787  *               boot record with a single image.
02788  *             - No emulation. You should specify load segment and load size
02789  *               of image.
02790  * @param catalog_path
02791  *      The absolute path in the image tree where the catalog will be stored.
02792  *      The directory component of this path must be a directory existent on
02793  *      the image tree, and the filename component must be unique among all
02794  *      children of that directory on image. Otherwise a correspodent error
02795  *      code will be returned. This function will add an IsoBoot node that acts
02796  *      as a placeholder for the real catalog, that will be generated at image
02797  *      creation time.
02798  * @param boot
02799  *      Location where a pointer to the added boot image will be stored. That
02800  *      object is owned by the IsoImage and should not be freed by the user,
02801  *      nor dereferenced once the last reference to the IsoImage was disposed
02802  *      via iso_image_unref(). A NULL value is allowed if you don't need a
02803  *      reference to the boot image.
02804  * @return
02805  *      1 on success, < 0 on error
02806  *
02807  * @since 0.6.2
02808  */
02809 int iso_image_set_boot_image(IsoImage *image, const char *image_path,
02810                              enum eltorito_boot_media_type type,
02811                              const char *catalog_path,
02812                              ElToritoBootImage **boot);
02813 
02814 /**
02815  * Add a further boot image to the set of El-Torito bootable images.
02816  * This set has already to be created by iso_image_set_boot_image().
02817  * Up to 31 further boot images may be added.
02818  *
02819  * @param image
02820  *      The image to which the boot image shall be added.
02821  *      returns an error and the image remains unmodified.
02822  * @param image_path
02823  *      The absolute path of a IsoFile to be used as default boot image.
02824  * @param type
02825  *      The boot media type. See iso_image_set_boot_image
02826  * @param flag
02827  *      Bitfield for control purposes. Unused yet. Submit 0.
02828  * @param boot
02829  *      Location where a pointer to the added boot image will be stored.
02830  *      See iso_image_set_boot_image
02831  * @return
02832  *      1 on success, < 0 on error
02833  *                    ISO_BOOT_NO_CATALOG means iso_image_set_boot_image()
02834  *                    was not called first.
02835  *
02836  * @since 0.6.32
02837  */
02838 int iso_image_add_boot_image(IsoImage *image, const char *image_path,
02839                              enum eltorito_boot_media_type type, int flag,
02840                              ElToritoBootImage **boot);
02841 
02842 /**
02843  * Get the El-Torito boot catalog and the default boot image of an ISO image.
02844  *
02845  * This can be useful, for example, to check if a volume read from a previous
02846  * session or an existing image is bootable. It can also be useful to get
02847  * the image and catalog tree nodes. An application would want those, for
02848  * example, to prevent the user removing it.
02849  *
02850  * Both nodes are owned by libisofs and should not be freed. You can get your
02851  * own ref with iso_node_ref(). You can also check if the node is already
02852  * on the tree by getting its parent (note that when reading El-Torito info
02853  * from a previous image, the nodes might not be on the tree even if you haven't
02854  * removed them). Remember that you'll need to get a new ref
02855  * (with iso_node_ref()) before inserting them again to the tree, and probably
02856  * you will also need to set the name or permissions.
02857  *
02858  * @param image
02859  *      The image from which to get the boot image.
02860  * @param boot
02861  *      If not NULL, it will be filled with a pointer to the boot image, if
02862  *      any. That  object is owned by the IsoImage and should not be freed by
02863  *      the user, nor dereferenced once the last reference to the IsoImage was
02864  *      disposed via iso_image_unref().
02865  * @param imgnode
02866  *      When not NULL, it will be filled with the image tree node. No extra ref
02867  *      is added, you can use iso_node_ref() to get one if you need it.
02868  * @param catnode
02869  *      When not NULL, it will be filled with the catnode tree node. No extra
02870  *      ref is added, you can use iso_node_ref() to get one if you need it.
02871  * @return
02872  *      1 on success, 0 is the image is not bootable (i.e., it has no El-Torito
02873  *      image), < 0 error.
02874  *
02875  * @since 0.6.2
02876  */
02877 int iso_image_get_boot_image(IsoImage *image, ElToritoBootImage **boot,
02878                              IsoFile **imgnode, IsoBoot **catnode);
02879 
02880 /**
02881  * Get detailed information about the boot catalog that was loaded from
02882  * an ISO image.
02883  * The boot catalog links the El Torito boot record at LBA 17 with the 
02884  * boot images which are IsoFile objects in the image. The boot catalog
02885  * itself is not a regular file and thus will not deliver an IsoStream.
02886  * Its content is usually quite short and can be obtained by this call.
02887  *
02888  * @param image
02889  *      The image to inquire.
02890  * @param catnode
02891  *      Will return the boot catalog tree node. No extra ref is taken.
02892  * @param lba
02893  *      Will return the block address of the boot catalog in the image.
02894  * @param content
02895  *      Will return either NULL or an allocated memory buffer with the
02896  *      content bytes of the boot catalog.
02897  *      Dispose it by free() when no longer needed.
02898  * @param size
02899  *      Will return the number of bytes in content.
02900  * @return
02901  *      1 if reply is valid, 0 if not boot catalog was loaded, < 0 on error.
02902  *
02903  * @since 1.1.2
02904  */
02905 int iso_image_get_bootcat(IsoImage *image, IsoBoot **catnode, uint32_t *lba,
02906                           char **content, off_t *size);
02907 
02908 
02909 /**
02910  * Get all El-Torito boot images of an ISO image.
02911  *
02912  * The first of these boot images is the same as returned by
02913  * iso_image_get_boot_image(). The others are alternative boot images. 
02914  *
02915  * @param image
02916  *      The image from which to get the boot images.
02917  * @param num_boots
02918  *      The number of available array elements in boots and bootnodes.
02919  * @param boots
02920  *      Returns NULL or an allocated array of pointers to boot images.
02921  *      Apply system call free(boots) to dispose it.
02922  * @param bootnodes
02923  *      Returns NULL or an allocated array of pointers to the IsoFile nodes
02924  *      which bear the content of the boot images in boots.
02925  * @param flag
02926  *      Bitfield for control purposes. Unused yet. Submit 0.
02927  * @return
02928  *      1 on success, 0 no El-Torito catalog and boot image attached,
02929  *      < 0 error.
02930  *
02931  * @since 0.6.32
02932  */
02933 int iso_image_get_all_boot_imgs(IsoImage *image, int *num_boots,
02934                    ElToritoBootImage ***boots, IsoFile ***bootnodes, int flag);
02935 
02936 
02937 /**
02938  * Removes all El-Torito boot images from the ISO image.
02939  *
02940  * The IsoBoot node that acts as placeholder for the catalog is also removed
02941  * for the image tree, if there.
02942  * If the image is not bootable (don't have el-torito boot image) this function
02943  * just returns.
02944  *
02945  * @since 0.6.2
02946  */
02947 void iso_image_remove_boot_image(IsoImage *image);
02948 
02949 /**
02950  * Sets the sort weight of the boot catalog that is attached to an IsoImage.
02951  * 
02952  * For the meaning of sort weights see iso_node_set_sort_weight().
02953  * That function cannot be applied to the emerging boot catalog because
02954  * it is not represented by an IsoFile.
02955  *
02956  * @param image
02957  *      The image to manipulate.
02958  * @param sort_weight
02959  *      The larger this value, the lower will be the block address of the
02960  *      boot catalog record.
02961  * @return
02962  *      0= no boot catalog attached , 1= ok , <0 = error
02963  *
02964  * @since 0.6.32
02965  */
02966 int iso_image_set_boot_catalog_weight(IsoImage *image, int sort_weight);
02967 
02968 /**
02969  * Hides the boot catalog file from directory trees.
02970  * 
02971  * For the meaning of hiding files see iso_node_set_hidden().
02972  *
02973  * 
02974  * @param image
02975  *      The image to manipulate.
02976  * @param hide_attrs
02977  *      Or-combination of values from enum IsoHideNodeFlag to set the trees
02978  *      in which the record.
02979  * @return
02980  *      0= no boot catalog attached , 1= ok , <0 = error
02981  *
02982  * @since 0.6.34
02983  */
02984 int iso_image_set_boot_catalog_hidden(IsoImage *image, int hide_attrs);
02985 
02986 
02987 /**
02988  * Get the boot media type as of parameter "type" of iso_image_set_boot_image()
02989  * resp. iso_image_add_boot_image().
02990  *
02991  * @param bootimg
02992  *      The image to inquire
02993  * @param media_type
02994  *      Returns the media type
02995  * @return
02996  *      1 = ok , < 0 = error
02997  *
02998  * @since 0.6.32
02999  */
03000 int el_torito_get_boot_media_type(ElToritoBootImage *bootimg, 
03001                                   enum eltorito_boot_media_type *media_type);
03002 
03003 /**
03004  * Sets the platform ID of the boot image.
03005  * 
03006  * The Platform ID gets written into the boot catalog at byte 1 of the
03007  * Validation Entry, or at byte 1 of a Section Header Entry.
03008  * If Platform ID and ID String of two consequtive bootimages are the same
03009  *
03010  * @param bootimg
03011  *      The image to manipulate.
03012  * @param id
03013  *      A Platform ID as of
03014  *      El Torito 1.0  : 0x00= 80x86,  0x01= PowerPC,  0x02= Mac
03015  *      Others         : 0xef= EFI
03016  * @return
03017  *      1 ok , <=0 error
03018  *
03019  * @since 0.6.32
03020  */
03021 int el_torito_set_boot_platform_id(ElToritoBootImage *bootimg, uint8_t id);
03022 
03023 /**
03024  * Get the platform ID value. See el_torito_set_boot_platform_id().
03025  *
03026  * @param bootimg
03027  *      The image to inquire
03028  * @return
03029  *      0 - 255 : The platform ID 
03030  *      < 0     : error
03031  *
03032  * @since 0.6.32
03033  */
03034 int el_torito_get_boot_platform_id(ElToritoBootImage *bootimg);
03035 
03036 /**
03037  * Sets the load segment for the initial boot image. This is only for
03038  * no emulation boot images, and is a NOP for other image types.
03039  *
03040  * @since 0.6.2
03041  */
03042 void el_torito_set_load_seg(ElToritoBootImage *bootimg, short segment);
03043 
03044 /**
03045  * Get the load segment value. See el_torito_set_load_seg().
03046  *
03047  * @param bootimg
03048  *      The image to inquire
03049  * @return
03050  *      0 - 65535 : The load segment value 
03051  *      < 0       : error
03052  *
03053  * @since 0.6.32
03054  */
03055 int el_torito_get_load_seg(ElToritoBootImage *bootimg);
03056 
03057 /**
03058  * Sets the number of sectors (512b) to be load at load segment during
03059  * the initial boot procedure. This is only for
03060  * no emulation boot images, and is a NOP for other image types.
03061  *
03062  * @since 0.6.2
03063  */
03064 void el_torito_set_load_size(ElToritoBootImage *bootimg, short sectors);
03065 
03066 /**
03067  * Get the load size. See el_torito_set_load_size().
03068  *
03069  * @param bootimg
03070  *      The image to inquire
03071  * @return
03072  *      0 - 65535 : The load size value
03073  *      < 0       : error
03074  *
03075  * @since 0.6.32
03076  */
03077 int el_torito_get_load_size(ElToritoBootImage *bootimg);
03078 
03079 /**
03080  * Marks the specified boot image as not bootable
03081  *
03082  * @since 0.6.2
03083  */
03084 void el_torito_set_no_bootable(ElToritoBootImage *bootimg);
03085 
03086 /**
03087  * Get the bootability flag. See el_torito_set_no_bootable().
03088  *
03089  * @param bootimg
03090  *      The image to inquire
03091  * @return
03092  *      0 = not bootable, 1 = bootable , <0 = error
03093  *
03094  * @since 0.6.32
03095  */
03096 int el_torito_get_bootable(ElToritoBootImage *bootimg);
03097 
03098 /**
03099  * Set the id_string of the Validation Entry resp. Sector Header Entry which
03100  * will govern the boot image Section Entry in the El Torito Catalog.
03101  *
03102  * @param bootimg
03103  *      The image to manipulate.
03104  * @param id_string
03105  *      The first boot image puts 24 bytes of ID string into the Validation
03106  *      Entry, where they shall "identify the manufacturer/developer of
03107  *      the CD-ROM".
03108  *      Further boot images put 28 bytes into their Section Header.
03109  *      El Torito 1.0 states that "If the BIOS understands the ID string, it
03110  *      may choose to boot the * system using one of these entries in place
03111  *      of the INITIAL/DEFAULT entry." (The INITIAL/DEFAULT entry points to the
03112  *      first boot image.)
03113  * @return
03114  *      1 = ok , <0 = error
03115  *
03116  * @since 0.6.32
03117  */
03118 int el_torito_set_id_string(ElToritoBootImage *bootimg, uint8_t id_string[28]);
03119 
03120 /** 
03121  * Get the id_string as of el_torito_set_id_string().
03122  *
03123  * @param bootimg
03124  *      The image to inquire
03125  * @param id_string
03126  *      Returns 28 bytes of id string
03127  * @return
03128  *      1 = ok , <0 = error
03129  *
03130  * @since 0.6.32
03131  */
03132 int el_torito_get_id_string(ElToritoBootImage *bootimg, uint8_t id_string[28]);
03133 
03134 /**
03135  * Set the Selection Criteria of a boot image.
03136  *
03137  * @param bootimg
03138  *      The image to manipulate.
03139  * @param crit
03140  *      The first boot image has no selection criteria. They will be ignored.
03141  *      Further boot images put 1 byte of Selection Criteria Type and 19
03142  *      bytes of data into their Section Entry.
03143  *      El Torito 1.0 states that "The format of the selection criteria is
03144  *      a function of the BIOS vendor. In the case of a foreign language
03145  *      BIOS three bytes would be used to identify the language".
03146  *      Type byte == 0 means "no criteria",
03147  *      type byte == 1 means "Language and Version Information (IBM)".
03148  * @return
03149  *      1 = ok , <0 = error
03150  *
03151  * @since 0.6.32
03152  */
03153 int el_torito_set_selection_crit(ElToritoBootImage *bootimg, uint8_t crit[20]);
03154 
03155 /** 
03156  * Get the Selection Criteria bytes as of el_torito_set_selection_crit().
03157  *
03158  * @param bootimg
03159  *      The image to inquire
03160  * @param id_string
03161  *      Returns 20 bytes of type and data
03162  * @return
03163  *      1 = ok , <0 = error
03164  *
03165  * @since 0.6.32
03166  */
03167 int el_torito_get_selection_crit(ElToritoBootImage *bootimg, uint8_t crit[20]);
03168 
03169 
03170 /**
03171  * Makes a guess whether the boot image was patched by a boot information
03172  * table. It is advisable to patch such boot images if their content gets
03173  * copied to a new location. See el_torito_set_isolinux_options().
03174  * Note: The reply can be positive only if the boot image was imported
03175  *       from an existing ISO image.
03176  *
03177  * @param bootimg
03178  *      The image to inquire
03179  * @param flag
03180  *        Reserved for future usage, set to 0.
03181  * @return
03182  *      1 = seems to contain oot info table , 0 = quite surely not
03183  * @since 0.6.32
03184  */
03185 int el_torito_seems_boot_info_table(ElToritoBootImage *bootimg, int flag);
03186 
03187 /**
03188  * Specifies options for ISOLINUX or GRUB boot images. This should only be used
03189  * if the type of boot image is known.
03190  *
03191  * @param bootimg
03192  *      The image to set options on 
03193  * @param options
03194  *        bitmask style flag. The following values are defined:
03195  *
03196  *        bit 0 -> 1 to patch the boot info table of the boot image.
03197  *                 1 does the same as mkisofs option -boot-info-table.
03198  *                 Needed for ISOLINUX or GRUB boot images with platform ID 0.
03199  *                 The table is located at byte 8 of the boot image file.
03200  *                 Its size is 56 bytes. 
03201  *                 The original boot image file on disk will not be modified.
03202  *
03203  *                 One may use el_torito_seems_boot_info_table() for a
03204  *                 qualified guess whether a boot info table is present in
03205  *                 the boot image. If the result is 1 then it should get bit0
03206  *                 set if its content gets copied to a new LBA.
03207  *
03208  *        bit 1 -> 1 to generate a ISOLINUX isohybrid image with MBR.
03209  *                 ----------------------------------------------------------
03210  *                 @deprecated since 31 Mar 2010:
03211  *                 The author of syslinux, H. Peter Anvin requested that this
03212  *                 feature shall not be used any more. He intends to cease
03213  *                 support for the MBR template that is included in libisofs.
03214  *                 ----------------------------------------------------------
03215  *                 A hybrid image is a boot image that boots from either
03216  *                 CD/DVD media or from disk-like media, e.g. USB stick.
03217  *                 For that you need isolinux.bin from SYSLINUX 3.72 or later.
03218  *                 IMPORTANT: The application has to take care that the image
03219  *                            on media gets padded up to the next full MB.
03220  * @param flag
03221  *        Reserved for future usage, set to 0.
03222  * @return
03223  *      1 success, < 0 on error
03224  * @since 0.6.12
03225  */
03226 int el_torito_set_isolinux_options(ElToritoBootImage *bootimg,
03227                                    int options, int flag);
03228 
03229 /** 
03230  * Get the options as of el_torito_set_isolinux_options().
03231  *
03232  * @param bootimg
03233  *      The image to inquire
03234  * @param flag
03235  *        Reserved for future usage, set to 0.
03236  * @return
03237  *      >= 0 returned option bits , <0 = error
03238  *
03239  * @since 0.6.32
03240  */
03241 int el_torito_get_isolinux_options(ElToritoBootImage *bootimg, int flag);
03242 
03243 /** Deprecated:
03244  * Specifies that this image needs to be patched. This involves the writing
03245  * of a 16 bytes boot information table at offset 8 of the boot image file.
03246  * The original boot image file won't be modified.
03247  * This is needed for isolinux boot images.
03248  *
03249  * @since 0.6.2
03250  * @deprecated Use el_torito_set_isolinux_options() instead
03251  */
03252 void el_torito_patch_isolinux_image(ElToritoBootImage *bootimg);
03253 
03254 /**
03255  * Obtain a copy of the eventually loaded first 32768 bytes of the imported
03256  * session, the System Area.
03257  * It will be written to the start of the next session unless it gets
03258  * overwritten by iso_write_opts_set_system_area().
03259  *
03260  * @param img
03261  *        The image to be inquired.
03262  * @param data
03263  *        A byte array of at least 32768 bytesi to take the loaded bytes.
03264  * @param options
03265  *        The option bits which will be applied if not overridden by
03266  *        iso_write_opts_set_system_area(). See there.
03267  * @param flag
03268  *        Bitfield for control purposes, unused yet, submit 0
03269  * @return
03270  *        1 on success, 0 if no System Area was loaded, < 0 error.
03271  * @since 0.6.30
03272  */
03273 int iso_image_get_system_area(IsoImage *img, char data[32768],
03274                               int *options, int flag);
03275 
03276 /**
03277  * Add a MIPS boot file path to the image.
03278  * Up to 15 such files can be written into a MIPS Big Endian Volume Header
03279  * if this is enabled by value 1 in iso_write_opts_set_system_area() option
03280  * bits 2 to 7. 
03281  * A single file can be written into a DEC Boot Block if this is enabled by
03282  * value 2 in iso_write_opts_set_system_area() option bits 2 to 7. So only
03283  * the first added file gets into effect with this system area type.
03284  * The data files which shall serve as MIPS boot files have to be brought into
03285  * the image by the normal means.
03286  * @param img
03287  *        The image to be manipulated.
03288  * @param path
03289  *        Absolute path of the boot file in the ISO 9660 Rock Ridge tree.
03290  * @param flag
03291  *        Bitfield for control purposes, unused yet, submit 0
03292  * @return
03293  *        1 on success, < 0 error
03294  * @since 0.6.38
03295  */
03296 int iso_image_add_mips_boot_file(IsoImage *image, char *path, int flag);
03297 
03298 /**
03299  * Obtain the number of added MIPS Big Endian boot files and pointers to
03300  * their paths in the ISO 9660 Rock Ridge tree.
03301  * @param img
03302  *        The image to be inquired.
03303  * @param paths
03304  *        An array of pointers to be set to the registered boot file paths.
03305  *        This are just pointers to data inside IsoImage. Do not free() them.
03306  *        Eventually make own copies of the data before manipulating the image.
03307  * @param flag
03308  *        Bitfield for control purposes, unused yet, submit 0
03309  * @return
03310  *        >= 0 is the number of valid path pointers , <0 means error
03311  * @since 0.6.38
03312  */
03313 int iso_image_get_mips_boot_files(IsoImage *image, char *paths[15], int flag);
03314 
03315 /**
03316  * Clear the list of MIPS Big Endian boot file paths.
03317  * @param img
03318  *        The image to be manipulated.
03319  * @param flag
03320  *        Bitfield for control purposes, unused yet, submit 0
03321  * @return
03322  *        1 is success , <0 means error
03323  * @since 0.6.38
03324  */
03325 int iso_image_give_up_mips_boot(IsoImage *image, int flag);
03326 
03327 
03328 /**
03329  * Increments the reference counting of the given node.
03330  *
03331  * @since 0.6.2
03332  */
03333 void iso_node_ref(IsoNode *node);
03334 
03335 /**
03336  * Decrements the reference couting of the given node.
03337  * If it reach 0, the node is free, and, if the node is a directory,
03338  * its children will be unref() too.
03339  *
03340  * @since 0.6.2
03341  */
03342 void iso_node_unref(IsoNode *node);
03343 
03344 /**
03345  * Get the type of an IsoNode.
03346  *
03347  * @since 0.6.2
03348  */
03349 enum IsoNodeType iso_node_get_type(IsoNode *node);
03350 
03351 /**
03352  * Class of functions to handle particular extended information. A function
03353  * instance acts as an identifier for the type of the information. Structs
03354  * with same information type must use a pointer to the same function.
03355  *
03356  * @param data
03357  *     Attached data
03358  * @param flag
03359  *     What to do with the data. At this time the following values are
03360  *     defined:
03361  *      -> 1 the data must be freed
03362  * @return
03363  *     1 in any case.
03364  *
03365  * @since 0.6.4
03366  */
03367 typedef int (*iso_node_xinfo_func)(void *data, int flag);
03368 
03369 /**
03370  * Add extended information to the given node. Extended info allows
03371  * applications (and libisofs itself) to add more information to an IsoNode.
03372  * You can use this facilities to associate temporary information with a given
03373  * node. This information is not written into the ISO 9660 image on media
03374  * and thus does not persist longer than the node memory object.
03375  *
03376  * Each node keeps a list of added extended info, meaning you can add several
03377  * extended info data to each node. Each extended info you add is identified
03378  * by the proc parameter, a pointer to a function that knows how to manage
03379  * the external info data. Thus, in order to add several types of extended
03380  * info, you need to define a "proc" function for each type.
03381  *
03382  * @param node
03383  *      The node where to add the extended info
03384  * @param proc
03385  *      A function pointer used to identify the type of the data, and that
03386  *      knows how to manage it
03387  * @param data
03388  *      Extended info to add.
03389  * @return
03390  *      1 if success, 0 if the given node already has extended info of the
03391  *      type defined by the "proc" function, < 0 on error
03392  *
03393  * @since 0.6.4
03394  */
03395 int iso_node_add_xinfo(IsoNode *node, iso_node_xinfo_func proc, void *data);
03396 
03397 /**
03398  * Remove the given extended info (defined by the proc function) from the
03399  * given node.
03400  *
03401  * @return
03402  *      1 on success, 0 if node does not have extended info of the requested
03403  *      type, < 0 on error
03404  *
03405  * @since 0.6.4
03406  */
03407 int iso_node_remove_xinfo(IsoNode *node, iso_node_xinfo_func proc);
03408 
03409 /**
03410  * Remove all extended information  from the given node.
03411  *
03412  * @param node
03413  *      The node where to remove all extended info
03414  * @param flag
03415  *      Bitfield for control purposes, unused yet, submit 0
03416  * @return
03417  *      1 on success, < 0 on error
03418  *      
03419  * @since 1.0.2
03420  */
03421 int iso_node_remove_all_xinfo(IsoNode *node, int flag);
03422 
03423 /**
03424  * Get the given extended info (defined by the proc function) from the
03425  * given node.
03426  *
03427  * @param node
03428  *      The node to inquire
03429  * @param proc
03430  *      The function pointer which serves as key
03431  * @param data
03432  *      Will be filled with the extended info corresponding to the given proc
03433  *      function
03434  * @return
03435  *      1 on success, 0 if node does not have extended info of the requested
03436  *      type, < 0 on error
03437  *
03438  * @since 0.6.4
03439  */
03440 int iso_node_get_xinfo(IsoNode *node, iso_node_xinfo_func proc, void **data);
03441 
03442 
03443 /**
03444  * Get the next pair of function pointer and data of an iteration of the
03445  * list of extended informations. Like:
03446  *     iso_node_xinfo_func proc;
03447  *     void *handle = NULL, *data; 
03448  *     while (iso_node_get_next_xinfo(node, &handle, &proc, &data) == 1) {
03449  *         ... make use of proc and data ...
03450  *     }
03451  * The iteration allocates no memory. So you may end it without any disposal
03452  * action.
03453  * IMPORTANT: Do not continue iterations after manipulating the extended
03454  *            information of a node. Memory corruption hazard !
03455  * @param node
03456  *      The node to inquire
03457  * @param  handle
03458  *      The opaque iteration handle. Initialize iteration by submitting
03459  *      a pointer to a void pointer with value NULL.
03460  *      Do not alter its content until iteration has ended.
03461  * @param proc
03462  *      The function pointer which serves as key
03463  * @param data
03464  *      Will be filled with the extended info corresponding to the given proc
03465  *      function
03466  * @return
03467  *      1 on success
03468  *      0 if iteration has ended (proc and data are invalid then)
03469  *      < 0 on error
03470  *
03471  * @since 1.0.2
03472  */
03473 int iso_node_get_next_xinfo(IsoNode *node, void **handle,
03474                             iso_node_xinfo_func *proc, void **data);
03475 
03476 
03477 /**
03478  * Class of functions to clone extended information. A function instance gets
03479  * associated to a particular iso_node_xinfo_func instance by function
03480  * iso_node_xinfo_make_clonable(). This is a precondition to have IsoNode
03481  * objects clonable which carry data for a particular iso_node_xinfo_func.
03482  *
03483  * @param old_data
03484  *     Data item to be cloned
03485  * @param new_data
03486  *     Shall return the cloned data item
03487  * @param flag
03488  *     Unused yet, submit 0
03489  *     The function shall return ISO_XINFO_NO_CLONE on unknown flag bits.
03490  * @return
03491  *     > 0 number of allocated bytes
03492  *       0 no size info is available
03493  *     < 0 error
03494  * 
03495  * @since 1.0.2
03496  */
03497 typedef int (*iso_node_xinfo_cloner)(void *old_data, void **new_data,int flag);
03498 
03499 /**
03500  * Associate a iso_node_xinfo_cloner to a particular class of extended
03501  * information in order to make it clonable.
03502  *
03503  * @param proc
03504  *     The key and disposal function which identifies the particular
03505  *     extended information class.
03506  * @param cloner
03507  *     The cloner function which shall be associated with proc.
03508  * @param flag
03509  *     Unused yet, submit 0
03510  * @return
03511  *     1 success, < 0 error
03512  * 
03513  * @since 1.0.2
03514  */
03515 int iso_node_xinfo_make_clonable(iso_node_xinfo_func proc,
03516                                  iso_node_xinfo_cloner cloner, int flag);
03517 
03518 /**
03519  * Inquire the registered cloner function for a particular class of
03520  * extended information.
03521  *
03522  * @param proc
03523  *     The key and disposal function which identifies the particular
03524  *     extended information class.
03525  * @param cloner
03526  *     Will return the cloner function which is associated with proc, or NULL.
03527  * @param flag
03528  *     Unused yet, submit 0
03529  * @return
03530  *     1 success, 0 no cloner registered for proc, < 0 error
03531  * 
03532  * @since 1.0.2
03533  */
03534 int iso_node_xinfo_get_cloner(iso_node_xinfo_func proc,
03535                               iso_node_xinfo_cloner *cloner, int flag);
03536 
03537 
03538 /**
03539  * Set the name of a node. Note that if the node is already added to a dir
03540  * this can fail if dir already contains a node with the new name.
03541  *
03542  * @param node
03543  *      The node whose name you want to change. Note that you can't change
03544  *      the name of the root.
03545  * @param name
03546  *      The name for the node. If you supply an empty string or a
03547  *      name greater than 255 characters this returns with failure, and
03548  *      node name is not modified.
03549  * @return
03550  *      1 on success, < 0 on error
03551  *
03552  * @since 0.6.2
03553  */
03554 int iso_node_set_name(IsoNode *node, const char *name);
03555 
03556 /**
03557  * Get the name of a node.
03558  * The returned string belongs to the node and should not be modified nor
03559  * freed. Use strdup if you really need your own copy.
03560  *
03561  * @since 0.6.2
03562  */
03563 const char *iso_node_get_name(const IsoNode *node);
03564 
03565 /**
03566  * Set the permissions for the node. This attribute is only useful when
03567  * Rock Ridge extensions are enabled.
03568  *
03569  * @param node
03570  *      The node to change
03571  * @param mode
03572  *     bitmask with the permissions of the node, as specified in 'man 2 stat'.
03573  *     The file type bitfields will be ignored, only file permissions will be
03574  *     modified.
03575  *
03576  * @since 0.6.2
03577  */
03578 void iso_node_set_permissions(IsoNode *node, mode_t mode);
03579 
03580 /**
03581  * Get the permissions for the node
03582  *
03583  * @since 0.6.2
03584  */
03585 mode_t iso_node_get_permissions(const IsoNode *node);
03586 
03587 /**
03588  * Get the mode of the node, both permissions and file type, as specified in
03589  * 'man 2 stat'.
03590  *
03591  * @since 0.6.2
03592  */
03593 mode_t iso_node_get_mode(const IsoNode *node);
03594 
03595 /**
03596  * Set the user id for the node. This attribute is only useful when
03597  * Rock Ridge extensions are enabled.
03598  *
03599  * @since 0.6.2
03600  */
03601 void iso_node_set_uid(IsoNode *node, uid_t uid);
03602 
03603 /**
03604  * Get the user id of the node.
03605  *
03606  * @since 0.6.2
03607  */
03608 uid_t iso_node_get_uid(const IsoNode *node);
03609 
03610 /**
03611  * Set the group id for the node. This attribute is only useful when
03612  * Rock Ridge extensions are enabled.
03613  *
03614  * @since 0.6.2
03615  */
03616 void iso_node_set_gid(IsoNode *node, gid_t gid);
03617 
03618 /**
03619  * Get the group id of the node.
03620  *
03621  * @since 0.6.2
03622  */
03623 gid_t iso_node_get_gid(const IsoNode *node);
03624 
03625 /**
03626  * Set the time of last modification of the file
03627  *
03628  * @since 0.6.2
03629  */
03630 void iso_node_set_mtime(IsoNode *node, time_t time);
03631 
03632 /**
03633  * Get the time of last modification of the file
03634  *
03635  * @since 0.6.2
03636  */
03637 time_t iso_node_get_mtime(const IsoNode *node);
03638 
03639 /**
03640  * Set the time of last access to the file
03641  *
03642  * @since 0.6.2
03643  */
03644 void iso_node_set_atime(IsoNode *node, time_t time);
03645 
03646 /**
03647  * Get the time of last access to the file
03648  *
03649  * @since 0.6.2
03650  */
03651 time_t iso_node_get_atime(const IsoNode *node);
03652 
03653 /**
03654  * Set the time of last status change of the file
03655  *
03656  * @since 0.6.2
03657  */
03658 void iso_node_set_ctime(IsoNode *node, time_t time);
03659 
03660 /**
03661  * Get the time of last status change of the file
03662  *
03663  * @since 0.6.2
03664  */
03665 time_t iso_node_get_ctime(const IsoNode *node);
03666 
03667 /**
03668  * Set whether the node will be hidden in the directory trees of RR/ISO 9660,
03669  * or of Joliet (if enabled at all), or of ISO-9660:1999 (if enabled at all).
03670  *
03671  * A hidden file does not show up by name in the affected directory tree.
03672  * For example, if a file is hidden only in Joliet, it will normally
03673  * not be visible on Windows systems, while being shown on GNU/Linux.
03674  *
03675  * If a file is not shown in any of the enabled trees, then its content will
03676  * not be written to the image, unless LIBISO_HIDE_BUT_WRITE is given (which
03677  * is available only since release 0.6.34).
03678  *
03679  * @param node
03680  *      The node that is to be hidden.
03681  * @param hide_attrs
03682  *      Or-combination of values from enum IsoHideNodeFlag to set the trees
03683  *      in which the node's name shall be hidden.
03684  *
03685  * @since 0.6.2
03686  */
03687 void iso_node_set_hidden(IsoNode *node, int hide_attrs);
03688 
03689 /**
03690  * Get the hide_attrs as eventually set by iso_node_set_hidden().
03691  *
03692  * @param node
03693  *      The node to inquire.
03694  * @return
03695  *      Or-combination of values from enum IsoHideNodeFlag which are
03696  *      currently set for the node.
03697  *
03698  * @since 0.6.34
03699  */
03700 int iso_node_get_hidden(IsoNode *node);
03701 
03702 /**
03703  * Compare two nodes whether they are based on the same input and
03704  * can be considered as hardlinks to the same file objects.
03705  *
03706  * @param n1
03707  *     The first node to compare.
03708  * @param n2
03709  *     The second node to compare.
03710  * @return
03711  *     -1 if s1 is smaller s2 , 0 if s1 matches s2 , 1 if s1 is larger s2
03712  * @param flag
03713  *     Bitfield for control purposes, unused yet, submit 0
03714  * @since 0.6.20
03715  */
03716 int iso_node_cmp_ino(IsoNode *n1, IsoNode *n2, int flag);
03717 
03718 /**
03719  * Add a new node to a dir. Note that this function don't add a new ref to
03720  * the node, so you don't need to free it, it will be automatically freed
03721  * when the dir is deleted. Of course, if you want to keep using the node
03722  * after the dir life, you need to iso_node_ref() it.
03723  *
03724  * @param dir
03725  *     the dir where to add the node
03726  * @param child
03727  *     the node to add. You must ensure that the node hasn't previously added
03728  *     to other dir, and that the node name is unique inside the child.
03729  *     Otherwise this function will return a failure, and the child won't be
03730  *     inserted.
03731  * @param replace
03732  *     if the dir already contains a node with the same name, whether to
03733  *     replace or not the old node with this.
03734  * @return
03735  *     number of nodes in dir if succes, < 0 otherwise
03736  *     Possible errors:
03737  *         ISO_NULL_POINTER, if dir or child are NULL
03738  *         ISO_NODE_ALREADY_ADDED, if child is already added to other dir
03739  *         ISO_NODE_NAME_NOT_UNIQUE, a node with same name already exists
03740  *         ISO_WRONG_ARG_VALUE, if child == dir, or replace != (0,1)
03741  *
03742  * @since 0.6.2
03743  */
03744 int iso_dir_add_node(IsoDir *dir, IsoNode *child,
03745                      enum iso_replace_mode replace);
03746 
03747 /**
03748  * Locate a node inside a given dir.
03749  *
03750  * @param dir
03751  *     The dir where to look for the node.
03752  * @param name
03753  *     The name of the node
03754  * @param node
03755  *     Location for a pointer to the node, it will filled with NULL if the dir
03756  *     doesn't have a child with the given name.
03757  *     The node will be owned by the dir and shouldn't be unref(). Just call
03758  *     iso_node_ref() to get your own reference to the node.
03759  *     Note that you can pass NULL is the only thing you want to do is check
03760  *     if a node with such name already exists on dir.
03761  * @return
03762  *     1 node found, 0 child has no such node, < 0 error
03763  *     Possible errors:
03764  *         ISO_NULL_POINTER, if dir or name are NULL
03765  *
03766  * @since 0.6.2
03767  */
03768 int iso_dir_get_node(IsoDir *dir, const char *name, IsoNode **node);
03769 
03770 /**
03771  * Get the number of children of a directory.
03772  *
03773  * @return
03774  *     >= 0 number of items, < 0 error
03775  *     Possible errors:
03776  *         ISO_NULL_POINTER, if dir is NULL
03777  *
03778  * @since 0.6.2
03779  */
03780 int iso_dir_get_children_count(IsoDir *dir);
03781 
03782 /**
03783  * Removes a child from a directory.
03784  * The child is not freed, so you will become the owner of the node. Later
03785  * you can add the node to another dir (calling iso_dir_add_node), or free
03786  * it if you don't need it (with iso_node_unref).
03787  *
03788  * @return
03789  *     1 on success, < 0 error
03790  *     Possible errors:
03791  *         ISO_NULL_POINTER, if node is NULL
03792  *         ISO_NODE_NOT_ADDED_TO_DIR, if node doesn't belong to a dir
03793  *
03794  * @since 0.6.2
03795  */
03796 int iso_node_take(IsoNode *node);
03797 
03798 /**
03799  * Removes a child from a directory and free (unref) it.
03800  * If you want to keep the child alive, you need to iso_node_ref() it
03801  * before this call, but in that case iso_node_take() is a better
03802  * alternative.
03803  *
03804  * @return
03805  *     1 on success, < 0 error
03806  *
03807  * @since 0.6.2
03808  */
03809 int iso_node_remove(IsoNode *node);
03810 
03811 /*
03812  * Get the parent of the given iso tree node. No extra ref is added to the
03813  * returned directory, you must take your ref. with iso_node_ref() if you
03814  * need it.
03815  *
03816  * If node is the root node, the same node will be returned as its parent.
03817  *
03818  * This returns NULL if the node doesn't pertain to any tree
03819  * (it was removed/taken).
03820  *
03821  * @since 0.6.2
03822  */
03823 IsoDir *iso_node_get_parent(IsoNode *node);
03824 
03825 /**
03826  * Get an iterator for the children of the given dir.
03827  *
03828  * You can iterate over the children with iso_dir_iter_next. When finished,
03829  * you should free the iterator with iso_dir_iter_free.
03830  * You musn't delete a child of the same dir, using iso_node_take() or
03831  * iso_node_remove(), while you're using the iterator. You can use
03832  * iso_dir_iter_take() or iso_dir_iter_remove() instead.
03833  *
03834  * You can use the iterator in the way like this
03835  *
03836  * IsoDirIter *iter;
03837  * IsoNode *node;
03838  * if ( iso_dir_get_children(dir, &iter) != 1 ) {
03839  *     // handle error
03840  * }
03841  * while ( iso_dir_iter_next(iter, &node) == 1 ) {
03842  *     // do something with the child
03843  * }
03844  * iso_dir_iter_free(iter);
03845  *
03846  * An iterator is intended to be used in a single iteration over the
03847  * children of a dir. Thus, it should be treated as a temporary object,
03848  * and free as soon as possible.
03849  *
03850  * @return
03851  *     1 success, < 0 error
03852  *     Possible errors:
03853  *         ISO_NULL_POINTER, if dir or iter are NULL
03854  *         ISO_OUT_OF_MEM
03855  *
03856  * @since 0.6.2
03857  */
03858 int iso_dir_get_children(const IsoDir *dir, IsoDirIter **iter);
03859 
03860 /**
03861  * Get the next child.
03862  * Take care that the node is owned by its parent, and will be unref() when
03863  * the parent is freed. If you want your own ref to it, call iso_node_ref()
03864  * on it.
03865  *
03866  * @return
03867  *     1 success, 0 if dir has no more elements, < 0 error
03868  *     Possible errors:
03869  *         ISO_NULL_POINTER, if node or iter are NULL
03870  *         ISO_ERROR, on wrong iter usage, usual caused by modiying the
03871  *         dir during iteration
03872  *
03873  * @since 0.6.2
03874  */
03875 int iso_dir_iter_next(IsoDirIter *iter, IsoNode **node);
03876 
03877 /**
03878  * Check if there're more children.
03879  *
03880  * @return
03881  *     1 dir has more elements, 0 no, < 0 error
03882  *     Possible errors:
03883  *         ISO_NULL_POINTER, if iter is NULL
03884  *
03885  * @since 0.6.2
03886  */
03887 int iso_dir_iter_has_next(IsoDirIter *iter);
03888 
03889 /**
03890  * Free a dir iterator.
03891  *
03892  * @since 0.6.2
03893  */
03894 void iso_dir_iter_free(IsoDirIter *iter);
03895 
03896 /**
03897  * Removes a child from a directory during an iteration, without freeing it.
03898  * It's like iso_node_take(), but to be used during a directory iteration.
03899  * The node removed will be the last returned by the iteration.
03900  *
03901  * If you call this function twice without calling iso_dir_iter_next between
03902  * them is not allowed and you will get an ISO_ERROR in second call.
03903  *
03904  * @return
03905  *     1 on succes, < 0 error
03906  *     Possible errors:
03907  *         ISO_NULL_POINTER, if iter is NULL
03908  *         ISO_ERROR, on wrong iter usage, for example by call this before
03909  *         iso_dir_iter_next.
03910  *
03911  * @since 0.6.2
03912  */
03913 int iso_dir_iter_take(IsoDirIter *iter);
03914 
03915 /**
03916  * Removes a child from a directory during an iteration and unref() it.
03917  * Like iso_node_remove(), but to be used during a directory iteration.
03918  * The node removed will be the one returned by the previous iteration.
03919  *
03920  * It is not allowed to call this function twice without calling
03921  * iso_dir_iter_next inbetween.
03922  *
03923  * @return
03924  *     1 on succes, < 0 error
03925  *     Possible errors:
03926  *         ISO_NULL_POINTER, if iter is NULL
03927  *         ISO_ERROR, on wrong iter usage, for example by calling this before
03928  *         iso_dir_iter_next.
03929  *
03930  * @since 0.6.2
03931  */
03932 int iso_dir_iter_remove(IsoDirIter *iter);
03933 
03934 /**
03935  * Removes a node by iso_node_remove() or iso_dir_iter_remove(). If the node
03936  * is a directory then the whole tree of nodes underneath is removed too.
03937  *
03938  * @param node
03939  *      The node to be removed.
03940  * @param iter
03941  *      If not NULL, then the node will be removed by iso_dir_iter_remove(iter)
03942  *      else it will be removed by iso_node_remove(node).
03943  * @return
03944  *      1 is success, <0 indicates error
03945  *
03946  * @since 1.0.2
03947  */
03948 int iso_node_remove_tree(IsoNode *node, IsoDirIter *boss_iter);
03949 
03950 
03951 /**
03952  * @since 0.6.4
03953  */
03954 typedef struct iso_find_condition IsoFindCondition;
03955 
03956 /**
03957  * Create a new condition that checks if the node name matches the given
03958  * wildcard.
03959  *
03960  * @param wildcard
03961  * @result
03962  *      The created IsoFindCondition, NULL on error.
03963  *
03964  * @since 0.6.4
03965  */
03966 IsoFindCondition *iso_new_find_conditions_name(const char *wildcard);
03967 
03968 /**
03969  * Create a new condition that checks the node mode against a mode mask. It
03970  * can be used to check both file type and permissions.
03971  *
03972  * For example:
03973  *
03974  * iso_new_find_conditions_mode(S_IFREG) : search for regular files
03975  * iso_new_find_conditions_mode(S_IFCHR | S_IWUSR) : search for character
03976  *     devices where owner has write permissions.
03977  *
03978  * @param mask
03979  *      Mode mask to AND against node mode.
03980  * @result
03981  *      The created IsoFindCondition, NULL on error.
03982  *
03983  * @since 0.6.4
03984  */
03985 IsoFindCondition *iso_new_find_conditions_mode(mode_t mask);
03986 
03987 /**
03988  * Create a new condition that checks the node gid.
03989  *
03990  * @param gid
03991  *      Desired Group Id.
03992  * @result
03993  *      The created IsoFindCondition, NULL on error.
03994  *
03995  * @since 0.6.4
03996  */
03997 IsoFindCondition *iso_new_find_conditions_gid(gid_t gid);
03998 
03999 /**
04000  * Create a new condition that checks the node uid.
04001  *
04002  * @param uid
04003  *      Desired User Id.
04004  * @result
04005  *      The created IsoFindCondition, NULL on error.
04006  *
04007  * @since 0.6.4
04008  */
04009 IsoFindCondition *iso_new_find_conditions_uid(uid_t uid);
04010 
04011 /**
04012  * Possible comparison between IsoNode and given conditions.
04013  *
04014  * @since 0.6.4
04015  */
04016 enum iso_find_comparisons {
04017     ISO_FIND_COND_GREATER,
04018     ISO_FIND_COND_GREATER_OR_EQUAL,
04019     ISO_FIND_COND_EQUAL,
04020     ISO_FIND_COND_LESS,
04021     ISO_FIND_COND_LESS_OR_EQUAL
04022 };
04023 
04024 /**
04025  * Create a new condition that checks the time of last access.
04026  *
04027  * @param time
04028  *      Time to compare against IsoNode atime.
04029  * @param comparison
04030  *      Comparison to be done between IsoNode atime and submitted time.
04031  *      Note that ISO_FIND_COND_GREATER, for example, is true if the node
04032  *      time is greater than the submitted time.
04033  * @result
04034  *      The created IsoFindCondition, NULL on error.
04035  *
04036  * @since 0.6.4
04037  */
04038 IsoFindCondition *iso_new_find_conditions_atime(time_t time,
04039                       enum iso_find_comparisons comparison);
04040 
04041 /**
04042  * Create a new condition that checks the time of last modification.
04043  *
04044  * @param time
04045  *      Time to compare against IsoNode mtime.
04046  * @param comparison
04047  *      Comparison to be done between IsoNode mtime and submitted time.
04048  *      Note that ISO_FIND_COND_GREATER, for example, is true if the node
04049  *      time is greater than the submitted time.
04050  * @result
04051  *      The created IsoFindCondition, NULL on error.
04052  *
04053  * @since 0.6.4
04054  */
04055 IsoFindCondition *iso_new_find_conditions_mtime(time_t time,
04056                       enum iso_find_comparisons comparison);
04057 
04058 /**
04059  * Create a new condition that checks the time of last status change.
04060  *
04061  * @param time
04062  *      Time to compare against IsoNode ctime.
04063  * @param comparison
04064  *      Comparison to be done between IsoNode ctime and submitted time.
04065  *      Note that ISO_FIND_COND_GREATER, for example, is true if the node
04066  *      time is greater than the submitted time.
04067  * @result
04068  *      The created IsoFindCondition, NULL on error.
04069  *
04070  * @since 0.6.4
04071  */
04072 IsoFindCondition *iso_new_find_conditions_ctime(time_t time,
04073                       enum iso_find_comparisons comparison);
04074 
04075 /**
04076  * Create a new condition that check if the two given conditions are
04077  * valid.
04078  *
04079  * @param a
04080  * @param b
04081  *      IsoFindCondition to compare
04082  * @result
04083  *      The created IsoFindCondition, NULL on error.
04084  *
04085  * @since 0.6.4
04086  */
04087 IsoFindCondition *iso_new_find_conditions_and(IsoFindCondition *a,
04088                                               IsoFindCondition *b);
04089 
04090 /**
04091  * Create a new condition that check if at least one the two given conditions
04092  * is valid.
04093  *
04094  * @param a
04095  * @param b
04096  *      IsoFindCondition to compare
04097  * @result
04098  *      The created IsoFindCondition, NULL on error.
04099  *
04100  * @since 0.6.4
04101  */
04102 IsoFindCondition *iso_new_find_conditions_or(IsoFindCondition *a,
04103                                               IsoFindCondition *b);
04104 
04105 /**
04106  * Create a new condition that check if the given conditions is false.
04107  *
04108  * @param negate
04109  * @result
04110  *      The created IsoFindCondition, NULL on error.
04111  *
04112  * @since 0.6.4
04113  */
04114 IsoFindCondition *iso_new_find_conditions_not(IsoFindCondition *negate);
04115 
04116 /**
04117  * Find all directory children that match the given condition.
04118  *
04119  * @param dir
04120  *      Directory where we will search children.
04121  * @param cond
04122  *      Condition that the children must match in order to be returned.
04123  *      It will be free together with the iterator. Remember to delete it
04124  *      if this function return error.
04125  * @param iter
04126  *      Iterator that returns only the children that match condition.
04127  * @return
04128  *      1 on success, < 0 on error
04129  *
04130  * @since 0.6.4
04131  */
04132 int iso_dir_find_children(IsoDir* dir, IsoFindCondition *cond,
04133                           IsoDirIter **iter);
04134 
04135 /**
04136  * Get the destination of a node.
04137  * The returned string belongs to the node and should not be modified nor
04138  * freed. Use strdup if you really need your own copy.
04139  *
04140  * @since 0.6.2
04141  */
04142 const char *iso_symlink_get_dest(const IsoSymlink *link);
04143 
04144 /**
04145  * Set the destination of a link.
04146  *
04147  * @param opts
04148  *     The option set to be manipulated
04149  * @param dest
04150  *     New destination for the link. It must be a non-empty string, otherwise
04151  *     this function doesn't modify previous destination.
04152  * @return
04153  *     1 on success, < 0 on error
04154  *
04155  * @since 0.6.2
04156  */
04157 int iso_symlink_set_dest(IsoSymlink *link, const char *dest);
04158 
04159 /**
04160  * Sets the order in which a node will be written on image. The data content
04161  * of files with high weight will be written to low block addresses.
04162  *
04163  * @param node
04164  *      The node which weight will be changed. If it's a dir, this function
04165  *      will change the weight of all its children. For nodes other that dirs
04166  *      or regular files, this function has no effect.
04167  * @param w
04168  *      The weight as a integer number, the greater this value is, the
04169  *      closer from the begining of image the file will be written.
04170  *      Default value at IsoNode creation is 0.
04171  *
04172  * @since 0.6.2
04173  */
04174 void iso_node_set_sort_weight(IsoNode *node, int w);
04175 
04176 /**
04177  * Get the sort weight of a file.
04178  *
04179  * @since 0.6.2
04180  */
04181 int iso_file_get_sort_weight(IsoFile *file);
04182 
04183 /**
04184  * Get the size of the file, in bytes
04185  *
04186  * @since 0.6.2
04187  */
04188 off_t iso_file_get_size(IsoFile *file);
04189 
04190 /**
04191  * Get the device id (major/minor numbers) of the given block or
04192  * character device file. The result is undefined for other kind
04193  * of special files, of first be sure iso_node_get_mode() returns either
04194  * S_IFBLK or S_IFCHR.
04195  *
04196  * @since 0.6.6
04197  */
04198 dev_t iso_special_get_dev(IsoSpecial *special);
04199 
04200 /**
04201  * Get the IsoStream that represents the contents of the given IsoFile.
04202  * The stream may be a filter stream which itself get its input from a
04203  * further stream. This may be inquired by iso_stream_get_input_stream().
04204  *
04205  * If you iso_stream_open() the stream, iso_stream_close() it before
04206  * image generation begins.
04207  *
04208  * @return
04209  *      The IsoStream. No extra ref is added, so the IsoStream belongs to the
04210  *      IsoFile, and it may be freed together with it. Add your own ref with
04211  *      iso_stream_ref() if you need it.
04212  *
04213  * @since 0.6.4
04214  */
04215 IsoStream *iso_file_get_stream(IsoFile *file);
04216 
04217 /**
04218  * Get the block lba of a file node, if it was imported from an old image.
04219  *
04220  * @param file
04221  *      The file
04222  * @param lba
04223  *      Will be filled with the kba
04224  * @param flag
04225  *      Reserved for future usage, submit 0
04226  * @return
04227  *      1 if lba is valid (file comes from old image), 0 if file was newly
04228  *      added, i.e. it does not come from an old image, < 0 error
04229  *
04230  * @since 0.6.4
04231  *
04232  * @deprecated Use iso_file_get_old_image_sections(), as this function does
04233  *             not work with multi-extend files.
04234  */
04235 int iso_file_get_old_image_lba(IsoFile *file, uint32_t *lba, int flag);
04236 
04237 /**
04238  * Get the start addresses and the sizes of the data extents of a file node
04239  * if it was imported from an old image.
04240  *
04241  * @param file
04242  *      The file
04243  * @param section_count
04244  *      Returns the number of extent entries in sections array.
04245  * @param sections
04246  *      Returns the array of file sections. Apply free() to dispose it.
04247  * @param flag
04248  *      Reserved for future usage, submit 0
04249  * @return
04250  *      1 if there are valid extents (file comes from old image),
04251  *      0 if file was newly added, i.e. it does not come from an old image,
04252  *      < 0 error
04253  *
04254  * @since 0.6.8
04255  */
04256 int iso_file_get_old_image_sections(IsoFile *file, int *section_count,
04257                                    struct iso_file_section **sections,
04258                                    int flag);
04259 
04260 /*
04261  * Like iso_file_get_old_image_lba(), but take an IsoNode.
04262  *
04263  * @return
04264  *      1 if lba is valid (file comes from old image), 0 if file was newly
04265  *      added, i.e. it does not come from an old image, 2 node type has no
04266  *      LBA (no regular file), < 0 error
04267  *
04268  * @since 0.6.4
04269  */
04270 int iso_node_get_old_image_lba(IsoNode *node, uint32_t *lba, int flag);
04271 
04272 /**
04273  * Add a new directory to the iso tree. Permissions, owner and hidden atts
04274  * are taken from parent, you can modify them later.
04275  *
04276  * @param parent
04277  *      the dir where the new directory will be created
04278  * @param name
04279  *      name for the new dir. If a node with same name already exists on
04280  *      parent, this functions fails with ISO_NODE_NAME_NOT_UNIQUE.
04281  * @param dir
04282  *      place where to store a pointer to the newly created dir. No extra
04283  *      ref is addded, so you will need to call iso_node_ref() if you really
04284  *      need it. You can pass NULL in this parameter if you don't need the
04285  *      pointer.
04286  * @return
04287  *     number of nodes in parent if success, < 0 otherwise
04288  *     Possible errors:
04289  *         ISO_NULL_POINTER, if parent or name are NULL
04290  *         ISO_NODE_NAME_NOT_UNIQUE, a node with same name already exists
04291  *         ISO_OUT_OF_MEM
04292  *
04293  * @since 0.6.2
04294  */
04295 int iso_tree_add_new_dir(IsoDir *parent, const char *name, IsoDir **dir);
04296 
04297 /**
04298  * Add a new regular file to the iso tree. Permissions are set to 0444,
04299  * owner and hidden atts are taken from parent. You can modify any of them
04300  * later.
04301  *
04302  * @param parent
04303  *      the dir where the new file will be created
04304  * @param name
04305  *      name for the new file. If a node with same name already exists on
04306  *      parent, this functions fails with ISO_NODE_NAME_NOT_UNIQUE.
04307  * @param stream
04308  *      IsoStream for the contents of the file. The reference will be taken
04309  *      by the newly created file, you will need to take an extra ref to it
04310  *      if you need it.
04311  * @param file
04312  *      place where to store a pointer to the newly created file. No extra
04313  *      ref is addded, so you will need to call iso_node_ref() if you really
04314  *      need it. You can pass NULL in this parameter if you don't need the
04315  *      pointer
04316  * @return
04317  *     number of nodes in parent if success, < 0 otherwise
04318  *     Possible errors:
04319  *         ISO_NULL_POINTER, if parent, name or dest are NULL
04320  *         ISO_NODE_NAME_NOT_UNIQUE, a node with same name already exists
04321  *         ISO_OUT_OF_MEM
04322  *
04323  * @since 0.6.4
04324  */
04325 int iso_tree_add_new_file(IsoDir *parent, const char *name, IsoStream *stream,
04326                           IsoFile **file);
04327 
04328 /**
04329  * Create an IsoStream object from content which is stored in a dynamically
04330  * allocated memory buffer. The new stream will become owner of the buffer
04331  * and apply free() to it when the stream finally gets destroyed itself.
04332  *
04333  * @param buf
04334  *     The dynamically allocated memory buffer with the stream content.
04335  * @parm size
04336  *     The number of bytes which may be read from buf.
04337  * @param stream
04338  *     Will return a reference to the newly created stream.
04339  * @return
04340  *     ISO_SUCCESS or <0 for error. E.g. ISO_NULL_POINTER, ISO_OUT_OF_MEM.
04341  *
04342  * @since 1.0.0
04343  */
04344 int iso_memory_stream_new(unsigned char *buf, size_t size, IsoStream **stream);
04345 
04346 /**
04347  * Add a new symlink to the directory tree. Permissions are set to 0777,
04348  * owner and hidden atts are taken from parent. You can modify any of them
04349  * later.
04350  *
04351  * @param parent
04352  *      the dir where the new symlink will be created
04353  * @param name
04354  *      name for the new symlink. If a node with same name already exists on
04355  *      parent, this functions fails with ISO_NODE_NAME_NOT_UNIQUE.
04356  * @param dest
04357  *      destination of the link
04358  * @param link
04359  *      place where to store a pointer to the newly created link. No extra
04360  *      ref is addded, so you will need to call iso_node_ref() if you really
04361  *      need it. You can pass NULL in this parameter if you don't need the
04362  *      pointer
04363  * @return
04364  *     number of nodes in parent if success, < 0 otherwise
04365  *     Possible errors:
04366  *         ISO_NULL_POINTER, if parent, name or dest are NULL
04367  *         ISO_NODE_NAME_NOT_UNIQUE, a node with same name already exists
04368  *         ISO_OUT_OF_MEM
04369  *
04370  * @since 0.6.2
04371  */
04372 int iso_tree_add_new_symlink(IsoDir *parent, const char *name,
04373                              const char *dest, IsoSymlink **link);
04374 
04375 /**
04376  * Add a new special file to the directory tree. As far as libisofs concerns,
04377  * an special file is a block device, a character device, a FIFO (named pipe)
04378  * or a socket. You can choose the specific kind of file you want to add
04379  * by setting mode propertly (see man 2 stat).
04380  *
04381  * Note that special files are only written to image when Rock Ridge
04382  * extensions are enabled. Moreover, a special file is just a directory entry
04383  * in the image tree, no data is written beyond that.
04384  *
04385  * Owner and hidden atts are taken from parent. You can modify any of them
04386  * later.
04387  *
04388  * @param parent
04389  *      the dir where the new special file will be created
04390  * @param name
04391  *      name for the new special file. If a node with same name already exists
04392  *      on parent, this functions fails with ISO_NODE_NAME_NOT_UNIQUE.
04393  * @param mode
04394  *      file type and permissions for the new node. Note that you can't
04395  *      specify any kind of file here, only special types are allowed. i.e,
04396  *      S_IFSOCK, S_IFBLK, S_IFCHR and S_IFIFO are valid types; S_IFLNK,
04397  *      S_IFREG and S_IFDIR aren't.
04398  * @param dev
04399  *      device ID, equivalent to the st_rdev field in man 2 stat.
04400  * @param special
04401  *      place where to store a pointer to the newly created special file. No
04402  *      extra ref is addded, so you will need to call iso_node_ref() if you
04403  *      really need it. You can pass NULL in this parameter if you don't need
04404  *      the pointer.
04405  * @return
04406  *     number of nodes in parent if success, < 0 otherwise
04407  *     Possible errors:
04408  *         ISO_NULL_POINTER, if parent, name or dest are NULL
04409  *         ISO_NODE_NAME_NOT_UNIQUE, a node with same name already exists
04410  *         ISO_WRONG_ARG_VALUE if you select a incorrect mode
04411  *         ISO_OUT_OF_MEM
04412  *
04413  * @since 0.6.2
04414  */
04415 int iso_tree_add_new_special(IsoDir *parent, const char *name, mode_t mode,
04416                              dev_t dev, IsoSpecial **special);
04417 
04418 /**
04419  * Set whether to follow or not symbolic links when added a file from a source
04420  * to IsoImage. Default behavior is to not follow symlinks.
04421  *
04422  * @since 0.6.2
04423  */
04424 void iso_tree_set_follow_symlinks(IsoImage *image, int follow);
04425 
04426 /**
04427  * Get current setting for follow_symlinks.
04428  *
04429  * @see iso_tree_set_follow_symlinks
04430  * @since 0.6.2
04431  */
04432 int iso_tree_get_follow_symlinks(IsoImage *image);
04433 
04434 /**
04435  * Set whether to skip or not disk files with names beginning by '.'
04436  * when adding a directory recursively.
04437  * Default behavior is to not ignore them.
04438  *
04439  * Clarification: This is not related to the IsoNode property to be hidden
04440  *                in one or more of the resulting image trees as of
04441  *                IsoHideNodeFlag and iso_node_set_hidden().
04442  *
04443  * @since 0.6.2
04444  */
04445 void iso_tree_set_ignore_hidden(IsoImage *image, int skip);
04446 
04447 /**
04448  * Get current setting for ignore_hidden.
04449  *
04450  * @see iso_tree_set_ignore_hidden
04451  * @since 0.6.2
04452  */
04453 int iso_tree_get_ignore_hidden(IsoImage *image);
04454 
04455 /**
04456  * Set the replace mode, that defines the behavior of libisofs when adding
04457  * a node whit the same name that an existent one, during a recursive
04458  * directory addition.
04459  *
04460  * @since 0.6.2
04461  */
04462 void iso_tree_set_replace_mode(IsoImage *image, enum iso_replace_mode mode);
04463 
04464 /**
04465  * Get current setting for replace_mode.
04466  *
04467  * @see iso_tree_set_replace_mode
04468  * @since 0.6.2
04469  */
04470 enum iso_replace_mode iso_tree_get_replace_mode(IsoImage *image);
04471 
04472 /**
04473  * Set whether to skip or not special files. Default behavior is to not skip
04474  * them. Note that, despite of this setting, special files will never be added
04475  * to an image unless RR extensions were enabled.
04476  *
04477  * @param image
04478  *      The image to manipulate.
04479  * @param skip
04480  *      Bitmask to determine what kind of special files will be skipped:
04481  *          bit0: ignore FIFOs
04482  *          bit1: ignore Sockets
04483  *          bit2: ignore char devices
04484  *          bit3: ignore block devices
04485  *
04486  * @since 0.6.2
04487  */
04488 void iso_tree_set_ignore_special(IsoImage *image, int skip);
04489 
04490 /**
04491  * Get current setting for ignore_special.
04492  *
04493  * @see iso_tree_set_ignore_special
04494  * @since 0.6.2
04495  */
04496 int iso_tree_get_ignore_special(IsoImage *image);
04497 
04498 /**
04499  * Add a excluded path. These are paths that won't never added to image, and
04500  * will be excluded even when adding recursively its parent directory.
04501  *
04502  * For example, in
04503  *
04504  *   iso_tree_add_exclude(image, "/home/user/data/private");
04505  *   iso_tree_add_dir_rec(image, root, "/home/user/data");
04506  *
04507  * the directory /home/user/data/private won't be added to image.
04508  *
04509  * However, if you explicity add a deeper dir, it won't be excluded. i.e.,
04510  * in the following example.
04511  *
04512  *   iso_tree_add_exclude(image, "/home/user/data");
04513  *   iso_tree_add_dir_rec(image, root, "/home/user/data/private");
04514  *
04515  * the directory /home/user/data/private is added. On the other, side, and
04516  * foollowing the the example above,
04517  *
04518  *   iso_tree_add_dir_rec(image, root, "/home/user");
04519  *
04520  * will exclude the directory "/home/user/data".
04521  *
04522  * Absolute paths are not mandatory, you can, for example, add a relative
04523  * path such as:
04524  *
04525  *   iso_tree_add_exclude(image, "private");
04526  *   iso_tree_add_exclude(image, "user/data");
04527  *
04528  * to excluve, respectively, all files or dirs named private, and also all
04529  * files or dirs named data that belong to a folder named "user". Not that the
04530  * above rule about deeper dirs is still valid. i.e., if you call
04531  *
04532  *   iso_tree_add_dir_rec(image, root, "/home/user/data/music");
04533  *
04534  * it is included even containing "user/data" string. However, a possible
04535  * "/home/user/data/music/user/data" is not added.
04536  *
04537  * Usual wildcards, such as * or ? are also supported, with the usual meaning
04538  * as stated in "man 7 glob". For example
04539  *
04540  * // to exclude backup text files
04541  * iso_tree_add_exclude(image, "*.~");
04542  *
04543  * @return
04544  *      1 on success, < 0 on error
04545  *
04546  * @since 0.6.2
04547  */
04548 int iso_tree_add_exclude(IsoImage *image, const char *path);
04549 
04550 /**
04551  * Remove a previously added exclude.
04552  *
04553  * @see iso_tree_add_exclude
04554  * @return
04555  *      1 on success, 0 exclude do not exists, < 0 on error
04556  *
04557  * @since 0.6.2
04558  */
04559 int iso_tree_remove_exclude(IsoImage *image, const char *path);
04560 
04561 /**
04562  * Set a callback function that libisofs will call for each file that is
04563  * added to the given image by a recursive addition function. This includes
04564  * image import.
04565  *
04566  * @param image
04567  *      The image to manipulate.
04568  * @param report
04569  *      pointer to a function that will be called just before a file will be
04570  *      added to the image. You can control whether the file will be in fact
04571  *      added or ignored.
04572  *      This function should return 1 to add the file, 0 to ignore it and
04573  *      continue, < 0 to abort the process
04574  *      NULL is allowed if you don't want any callback.
04575  *
04576  * @since 0.6.2
04577  */
04578 void iso_tree_set_report_callback(IsoImage *image,
04579                                   int (*report)(IsoImage*, IsoFileSource*));
04580 
04581 /**
04582  * Add a new node to the image tree, from an existing file.
04583  *
04584  * TODO comment Builder and Filesystem related issues when exposing both
04585  *
04586  * All attributes will be taken from the source file. The appropriate file
04587  * type will be created.
04588  *
04589  * @param image
04590  *      The image
04591  * @param parent
04592  *      The directory in the image tree where the node will be added.
04593  * @param path
04594  *      The absolute path of the file in the local filesystem.
04595  *      The node will have the same leaf name as the file on disk.
04596  *      Its directory path depends on the parent node.
04597  * @param node
04598  *      place where to store a pointer to the newly added file. No
04599  *      extra ref is addded, so you will need to call iso_node_ref() if you
04600  *      really need it. You can pass NULL in this parameter if you don't need
04601  *      the pointer.
04602  * @return
04603  *     number of nodes in parent if success, < 0 otherwise
04604  *     Possible errors:
04605  *         ISO_NULL_POINTER, if image, parent or path are NULL
04606  *         ISO_NODE_NAME_NOT_UNIQUE, a node with same name already exists
04607  *         ISO_OUT_OF_MEM
04608  *
04609  * @since 0.6.2
04610  */
04611 int iso_tree_add_node(IsoImage *image, IsoDir *parent, const char *path,
04612                       IsoNode **node);
04613 
04614 /**
04615  * This is a more versatile form of iso_tree_add_node which allows to set
04616  * the node name in ISO image already when it gets added. 
04617  *
04618  * Add a new node to the image tree, from an existing file, and with the
04619  * given name, that must not exist on dir.
04620  *
04621  * @param image
04622  *      The image
04623  * @param parent
04624  *      The directory in the image tree where the node will be added.
04625  * @param name
04626  *      The leaf name that the node will have on image.
04627  *      Its directory path depends on the parent node.
04628  * @param path
04629  *      The absolute path of the file in the local filesystem.
04630  * @param node
04631  *      place where to store a pointer to the newly added file. No
04632  *      extra ref is addded, so you will need to call iso_node_ref() if you
04633  *      really need it. You can pass NULL in this parameter if you don't need
04634  *      the pointer.
04635  * @return
04636  *     number of nodes in parent if success, < 0 otherwise
04637  *     Possible errors:
04638  *         ISO_NULL_POINTER, if image, parent or path are NULL
04639  *         ISO_NODE_NAME_NOT_UNIQUE, a node with same name already exists
04640  *         ISO_OUT_OF_MEM
04641  *
04642  * @since 0.6.4
04643  */
04644 int iso_tree_add_new_node(IsoImage *image, IsoDir *parent, const char *name,
04645                           const char *path, IsoNode **node);
04646 
04647 /**
04648  * Add a new node to the image tree with the given name that must not exist
04649  * on dir. The node data content will be a byte interval out of the data
04650  * content of a file in the local filesystem.
04651  *
04652  * @param image
04653  *      The image
04654  * @param parent
04655  *      The directory in the image tree where the node will be added.
04656  * @param name
04657  *      The leaf name that the node will have on image.
04658  *      Its directory path depends on the parent node.
04659  * @param path
04660  *      The absolute path of the file in the local filesystem. For now
04661  *      only regular files and symlinks to regular files are supported.
04662  * @param offset
04663  *      Byte number in the given file from where to start reading data.
04664  * @param size
04665  *      Max size of the file. This may be more than actually available from
04666  *      byte offset to the end of the file in the local filesystem.
04667  * @param node
04668  *      place where to store a pointer to the newly added file. No
04669  *      extra ref is addded, so you will need to call iso_node_ref() if you
04670  *      really need it. You can pass NULL in this parameter if you don't need
04671  *      the pointer.
04672  * @return
04673  *     number of nodes in parent if success, < 0 otherwise
04674  *     Possible errors:
04675  *         ISO_NULL_POINTER, if image, parent or path are NULL
04676  *         ISO_NODE_NAME_NOT_UNIQUE, a node with same name already exists
04677  *         ISO_OUT_OF_MEM
04678  *
04679  * @since 0.6.4
04680  */
04681 int iso_tree_add_new_cut_out_node(IsoImage *image, IsoDir *parent,
04682                                   const char *name, const char *path,
04683                                   off_t offset, off_t size,
04684                                   IsoNode **node);
04685 
04686 /**
04687  * Create a copy of the given node under a different path. If the node is
04688  * actually a directory then clone its whole subtree.
04689  * This call may fail because an IsoFile is encountered which gets fed by an
04690  * IsoStream which cannot be cloned. See also IsoStream_Iface method
04691  * clone_stream().
04692  * Surely clonable node types are:
04693  *   IsoDir,
04694  *   IsoSymlink,
04695  *   IsoSpecial,
04696  *   IsoFile from a loaded ISO image,
04697  *   IsoFile referring to local filesystem files,
04698  *   IsoFile created by iso_tree_add_new_file
04699  *           from a stream created by iso_memory_stream_new(),
04700  *   IsoFile created by iso_tree_add_new_cut_out_node()
04701  * Silently ignored are nodes of type IsoBoot.
04702  * An IsoFile node with IsoStream filters can be cloned if all those filters
04703  * are clonable and the node would be clonable without filter.
04704  * Clonable IsoStream filters are created by:
04705  *   iso_file_add_zisofs_filter()
04706  *   iso_file_add_gzip_filter()
04707  *   iso_file_add_external_filter()
04708  * An IsoNode with extended information as of iso_node_add_xinfo() can only be
04709  * cloned if each of the iso_node_xinfo_func instances is associated to a
04710  * clone function. See iso_node_xinfo_make_clonable().
04711  * All internally used classes of extended information are clonable.
04712  * 
04713  * @param node
04714  *      The node to be cloned.
04715  * @param new_parent
04716  *      The existing directory node where to insert the cloned node.
04717  * @param new_name
04718  *      The name for the cloned node. It must not yet exist in new_parent,
04719  *      unless it is a directory and node is a directory and flag bit0 is set.
04720  * @param new_node
04721  *      Will return a pointer (without reference) to the newly created clone.
04722  * @param flag
04723  *      Bitfield for control purposes. Submit any undefined bits as 0.
04724  *      bit0= Merge directories rather than returning ISO_NODE_NAME_NOT_UNIQUE.
04725  *            This will not allow to overwrite any existing node.
04726  *            Attributes of existing directories will not be overwritten.
04727  * @return
04728  *      <0 means error, 1 = new node created,
04729  *      2 = if flag bit0 is set: new_node is a directory which already existed.
04730  *
04731  * @since 1.0.2
04732  */
04733 int iso_tree_clone(IsoNode *node,
04734                    IsoDir *new_parent, char *new_name, IsoNode **new_node,
04735                    int flag);
04736 
04737 /**
04738  * Add the contents of a dir to a given directory of the iso tree.
04739  *
04740  * There are several options to control what files are added or how they are
04741  * managed. Take a look at iso_tree_set_* functions to see diferent options
04742  * for recursive directory addition.
04743  *
04744  * TODO comment Builder and Filesystem related issues when exposing both
04745  *
04746  * @param image
04747  *      The image to which the directory belongs.
04748  * @param parent
04749  *      Directory on the image tree where to add the contents of the dir
04750  * @param dir
04751  *      Path to a dir in the filesystem
04752  * @return
04753  *     number of nodes in parent if success, < 0 otherwise
04754  *
04755  * @since 0.6.2
04756  */
04757 int iso_tree_add_dir_rec(IsoImage *image, IsoDir *parent, const char *dir);
04758 
04759 /**
04760  * Locate a node by its absolute path on image.
04761  *
04762  * @param image
04763  *     The image to which the node belongs.
04764  * @param node
04765  *     Location for a pointer to the node, it will filled with NULL if the
04766  *     given path does not exists on image.
04767  *     The node will be owned by the image and shouldn't be unref(). Just call
04768  *     iso_node_ref() to get your own reference to the node.
04769  *     Note that you can pass NULL is the only thing you want to do is check
04770  *     if a node with such path really exists.
04771  * @return
04772  *      1 found, 0 not found, < 0 error
04773  *
04774  * @since 0.6.2
04775  */
04776 int iso_tree_path_to_node(IsoImage *image, const char *path, IsoNode **node);
04777 
04778 /**
04779  * Get the absolute path on image of the given node.
04780  *
04781  * @return
04782  *      The path on the image, that must be freed when no more needed. If the
04783  *      given node is not added to any image, this returns NULL.
04784  * @since 0.6.4
04785  */
04786 char *iso_tree_get_node_path(IsoNode *node);
04787 
04788 /**
04789  * Increments the reference counting of the given IsoDataSource.
04790  *
04791  * @since 0.6.2
04792  */
04793 void iso_data_source_ref(IsoDataSource *src);
04794 
04795 /**
04796  * Decrements the reference counting of the given IsoDataSource, freeing it
04797  * if refcount reach 0.
04798  *
04799  * @since 0.6.2
04800  */
04801 void iso_data_source_unref(IsoDataSource *src);
04802 
04803 /**
04804  * Create a new IsoDataSource from a local file. This is suitable for
04805  * accessing regular files or block devices with ISO images.
04806  *
04807  * @param path
04808  *     The absolute path of the file
04809  * @param src
04810  *     Will be filled with the pointer to the newly created data source.
04811  * @return
04812  *    1 on success, < 0 on error.
04813  *
04814  * @since 0.6.2
04815  */
04816 int iso_data_source_new_from_file(const char *path, IsoDataSource **src);
04817 
04818 /**
04819  * Get the status of the buffer used by a burn_source.
04820  *
04821  * @param b
04822  *      A burn_source previously obtained with
04823  *      iso_image_create_burn_source().
04824  * @param size
04825  *      Will be filled with the total size of the buffer, in bytes
04826  * @param free_bytes
04827  *      Will be filled with the bytes currently available in buffer
04828  * @return
04829  *      < 0 error, > 0 state:
04830  *           1="active"    : input and consumption are active
04831  *           2="ending"    : input has ended without error
04832  *           3="failing"   : input had error and ended,
04833  *           5="abandoned" : consumption has ended prematurely
04834  *           6="ended"     : consumption has ended without input error
04835  *           7="aborted"   : consumption has ended after input error
04836  *
04837  * @since 0.6.2
04838  */
04839 int iso_ring_buffer_get_status(struct burn_source *b, size_t *size,
04840                                size_t *free_bytes);
04841 
04842 #define ISO_MSGS_MESSAGE_LEN 4096
04843 
04844 /**
04845  * Control queueing and stderr printing of messages from libisofs.
04846  * Severity may be one of "NEVER", "FATAL", "SORRY", "WARNING", "HINT",
04847  * "NOTE", "UPDATE", "DEBUG", "ALL".
04848  *
04849  * @param queue_severity Gives the minimum limit for messages to be queued.
04850  *                       Default: "NEVER". If you queue messages then you
04851  *                       must consume them by iso_msgs_obtain().
04852  * @param print_severity Does the same for messages to be printed directly
04853  *                       to stderr.
04854  * @param print_id       A text prefix to be printed before the message.
04855  * @return               >0 for success, <=0 for error
04856  *
04857  * @since 0.6.2
04858  */
04859 int iso_set_msgs_severities(char *queue_severity, char *print_severity,
04860                             char *print_id);
04861 
04862 /**
04863  * Obtain the oldest pending libisofs message from the queue which has at
04864  * least the given minimum_severity. This message and any older message of
04865  * lower severity will get discarded from the queue and is then lost forever.
04866  *
04867  * Severity may be one of "NEVER", "FATAL", "SORRY", "WARNING", "HINT",
04868  * "NOTE", "UPDATE", "DEBUG", "ALL". To call with minimum_severity "NEVER"
04869  * will discard the whole queue.
04870  *
04871  * @param minimum_severity
04872  *     Threshhold
04873  * @param error_code
04874  *     Will become a unique error code as listed at the end of this header
04875  * @param imgid
04876  *     Id of the image that was issued the message.
04877  * @param msg_text
04878  *     Must provide at least ISO_MSGS_MESSAGE_LEN bytes.
04879  * @param severity
04880  *     Will become the severity related to the message and should provide at
04881  *     least 80 bytes.
04882  * @return
04883  *     1 if a matching item was found, 0 if not, <0 for severe errors
04884  *
04885  * @since 0.6.2
04886  */
04887 int iso_obtain_msgs(char *minimum_severity, int *error_code, int *imgid,
04888                     char msg_text[], char severity[]);
04889 
04890 
04891 /**
04892  * Submit a message to the libisofs queueing system. It will be queued or
04893  * printed as if it was generated by libisofs itself.
04894  *
04895  * @param error_code
04896  *      The unique error code of your message.
04897  *      Submit 0 if you do not have reserved error codes within the libburnia
04898  *      project.
04899  * @param msg_text
04900  *      Not more than ISO_MSGS_MESSAGE_LEN characters of message text.
04901  * @param os_errno
04902  *      Eventual errno related to the message. Submit 0 if the message is not
04903  *      related to a operating system error.
04904  * @param severity
04905  *      One of "ABORT", "FATAL", "FAILURE", "SORRY", "WARNING", "HINT", "NOTE",
04906  *      "UPDATE", "DEBUG". Defaults to "FATAL".
04907  * @param origin
04908  *      Submit 0 for now.
04909  * @return
04910  *      1 if message was delivered, <=0 if failure
04911  *
04912  * @since 0.6.4
04913  */
04914 int iso_msgs_submit(int error_code, char msg_text[], int os_errno,
04915                     char severity[], int origin);
04916 
04917 
04918 /**
04919  * Convert a severity name into a severity number, which gives the severity
04920  * rank of the name.
04921  *
04922  * @param severity_name
04923  *      A name as with iso_msgs_submit(), e.g. "SORRY".
04924  * @param severity_number
04925  *      The rank number: the higher, the more severe.
04926  * @return
04927  *      >0 success, <=0 failure
04928  *
04929  * @since 0.6.4
04930  */
04931 int iso_text_to_sev(char *severity_name, int *severity_number);
04932 
04933 
04934 /**
04935  * Convert a severity number into a severity name
04936  *
04937  * @param severity_number
04938  *      The rank number: the higher, the more severe.
04939  * @param severity_name
04940  *      A name as with iso_msgs_submit(), e.g. "SORRY".
04941  *
04942  * @since 0.6.4
04943  */
04944 int iso_sev_to_text(int severity_number, char **severity_name);
04945 
04946 
04947 /**
04948  * Get the id of an IsoImage, used for message reporting. This message id,
04949  * retrieved with iso_obtain_msgs(), can be used to distinguish what
04950  * IsoImage has isssued a given message.
04951  *
04952  * @since 0.6.2
04953  */
04954 int iso_image_get_msg_id(IsoImage *image);
04955 
04956 /**
04957  * Get a textual description of a libisofs error.
04958  *
04959  * @since 0.6.2
04960  */
04961 const char *iso_error_to_msg(int errcode);
04962 
04963 /**
04964  * Get the severity of a given error code
04965  * @return
04966  *       0x10000000 -> DEBUG
04967  *       0x20000000 -> UPDATE
04968  *       0x30000000 -> NOTE
04969  *       0x40000000 -> HINT
04970  *       0x50000000 -> WARNING
04971  *       0x60000000 -> SORRY
04972  *       0x64000000 -> MISHAP
04973  *       0x68000000 -> FAILURE
04974  *       0x70000000 -> FATAL
04975  *       0x71000000 -> ABORT
04976  *
04977  * @since 0.6.2
04978  */
04979 int iso_error_get_severity(int e);
04980 
04981 /**
04982  * Get the priority of a given error.
04983  * @return
04984  *      0x00000000 -> ZERO
04985  *      0x10000000 -> LOW
04986  *      0x20000000 -> MEDIUM
04987  *      0x30000000 -> HIGH
04988  *
04989  * @since 0.6.2
04990  */
04991 int iso_error_get_priority(int e);
04992 
04993 /**
04994  * Get the message queue code of a libisofs error.
04995  */
04996 int iso_error_get_code(int e);
04997 
04998 /**
04999  * Set the minimum error severity that causes a libisofs operation to
05000  * be aborted as soon as possible.
05001  *
05002  * @param severity
05003  *      one of "FAILURE", "MISHAP", "SORRY", "WARNING", "HINT", "NOTE".
05004  *      Severities greater or equal than FAILURE always cause program to abort.
05005  *      Severities under NOTE won't never cause function abort.
05006  * @return
05007  *      Previous abort priority on success, < 0 on error.
05008  *
05009  * @since 0.6.2
05010  */
05011 int iso_set_abort_severity(char *severity);
05012 
05013 /**
05014  * Return the messenger object handle used by libisofs. This handle
05015  * may be used by related libraries to  their own compatible
05016  * messenger objects and thus to direct their messages to the libisofs
05017  * message queue. See also: libburn, API function burn_set_messenger().
05018  *
05019  * @return the handle. Do only use with compatible
05020  *
05021  * @since 0.6.2
05022  */
05023 void *iso_get_messenger();
05024 
05025 /**
05026  * Take a ref to the given IsoFileSource.
05027  *
05028  * @since 0.6.2
05029  */
05030 void iso_file_source_ref(IsoFileSource *src);
05031 
05032 /**
05033  * Drop your ref to the given IsoFileSource, eventually freeing the associated
05034  * system resources.
05035  *
05036  * @since 0.6.2
05037  */
05038 void iso_file_source_unref(IsoFileSource *src);
05039 
05040 /*
05041  * this are just helpers to invoque methods in class
05042  */
05043 
05044 /**
05045  * Get the absolute path in the filesystem this file source belongs to.
05046  *
05047  * @return
05048  *     the path of the FileSource inside the filesystem, it should be
05049  *     freed when no more needed.
05050  *
05051  * @since 0.6.2
05052  */
05053 char* iso_file_source_get_path(IsoFileSource *src);
05054 
05055 /**
05056  * Get the name of the file, with the dir component of the path.
05057  *
05058  * @return
05059  *     the name of the file, it should be freed when no more needed.
05060  *
05061  * @since 0.6.2
05062  */
05063 char* iso_file_source_get_name(IsoFileSource *src);
05064 
05065 /**
05066  * Get information about the file.
05067  * @return
05068  *    1 success, < 0 error
05069  *      Error codes:
05070  *         ISO_FILE_ACCESS_DENIED
05071  *         ISO_FILE_BAD_PATH
05072  *         ISO_FILE_DOESNT_EXIST
05073  *         ISO_OUT_OF_MEM
05074  *         ISO_FILE_ERROR
05075  *         ISO_NULL_POINTER
05076  *
05077  * @since 0.6.2
05078  */
05079 int iso_file_source_lstat(IsoFileSource *src, struct stat *info);
05080 
05081 /**
05082  * Check if the process has access to read file contents. Note that this
05083  * is not necessarily related with (l)stat functions. For example, in a
05084  * filesystem implementation to deal with an ISO image, if the user has
05085  * read access to the image it will be able to read all files inside it,
05086  * despite of the particular permission of each file in the RR tree, that
05087  * are what the above functions return.
05088  *
05089  * @return
05090  *     1 if process has read access, < 0 on error
05091  *      Error codes:
05092  *         ISO_FILE_ACCESS_DENIED
05093  *         ISO_FILE_BAD_PATH
05094  *         ISO_FILE_DOESNT_EXIST
05095  *         ISO_OUT_OF_MEM
05096  *         ISO_FILE_ERROR
05097  *         ISO_NULL_POINTER
05098  *
05099  * @since 0.6.2
05100  */
05101 int iso_file_source_access(IsoFileSource *src);
05102 
05103 /**
05104  * Get information about the file. If the file is a symlink, the info
05105  * returned refers to the destination.
05106  *
05107  * @return
05108  *    1 success, < 0 error
05109  *      Error codes:
05110  *         ISO_FILE_ACCESS_DENIED
05111  *         ISO_FILE_BAD_PATH
05112  *         ISO_FILE_DOESNT_EXIST
05113  *         ISO_OUT_OF_MEM
05114  *         ISO_FILE_ERROR
05115  *         ISO_NULL_POINTER
05116  *
05117  * @since 0.6.2
05118  */
05119 int iso_file_source_stat(IsoFileSource *src, struct stat *info);
05120 
05121 /**
05122  * Opens the source.
05123  * @return 1 on success, < 0 on error
05124  *      Error codes:
05125  *         ISO_FILE_ALREADY_OPENED
05126  *         ISO_FILE_ACCESS_DENIED
05127  *         ISO_FILE_BAD_PATH
05128  *         ISO_FILE_DOESNT_EXIST
05129  *         ISO_OUT_OF_MEM
05130  *         ISO_FILE_ERROR
05131  *         ISO_NULL_POINTER
05132  *
05133  * @since 0.6.2
05134  */
05135 int iso_file_source_open(IsoFileSource *src);
05136 
05137 /**
05138  * Close a previuously openned file
05139  * @return 1 on success, < 0 on error
05140  *      Error codes:
05141  *         ISO_FILE_ERROR
05142  *         ISO_NULL_POINTER
05143  *         ISO_FILE_NOT_OPENED
05144  *
05145  * @since 0.6.2
05146  */
05147 int iso_file_source_close(IsoFileSource *src);
05148 
05149 /**
05150  * Attempts to read up to count bytes from the given source into
05151  * the buffer starting at buf.
05152  *
05153  * The file src must be open() before calling this, and close() when no
05154  * more needed. Not valid for dirs. On symlinks it reads the destination
05155  * file.
05156  *
05157  * @param src
05158  *     The given source
05159  * @param buf
05160  *     Pointer to a buffer of at least count bytes where the read data will be
05161  *     stored
05162  * @param count
05163  *     Bytes to read
05164  * @return
05165  *     number of bytes read, 0 if EOF, < 0 on error
05166  *      Error codes:
05167  *         ISO_FILE_ERROR
05168  *         ISO_NULL_POINTER
05169  *         ISO_FILE_NOT_OPENED
05170  *         ISO_WRONG_ARG_VALUE -> if count == 0
05171  *         ISO_FILE_IS_DIR
05172  *         ISO_OUT_OF_MEM
05173  *         ISO_INTERRUPTED
05174  *
05175  * @since 0.6.2
05176  */
05177 int iso_file_source_read(IsoFileSource *src, void *buf, size_t count);
05178 
05179 /**
05180  * Repositions the offset of the given IsoFileSource (must be opened) to the
05181  * given offset according to the value of flag.
05182  *
05183  * @param src
05184  *     The given source
05185  * @param offset
05186  *      in bytes
05187  * @param flag
05188  *      0 The offset is set to offset bytes (SEEK_SET)
05189  *      1 The offset is set to its current location plus offset bytes
05190  *        (SEEK_CUR)
05191  *      2 The offset is set to the size of the file plus offset bytes
05192  *        (SEEK_END).
05193  * @return
05194  *      Absolute offset posistion on the file, or < 0 on error. Cast the
05195  *      returning value to int to get a valid libisofs error.
05196  * @since 0.6.4
05197  */
05198 off_t iso_file_source_lseek(IsoFileSource *src, off_t offset, int flag);
05199 
05200 /**
05201  * Read a directory.
05202  *
05203  * Each call to this function will return a new child, until we reach
05204  * the end of file (i.e, no more children), in that case it returns 0.
05205  *
05206  * The dir must be open() before calling this, and close() when no more
05207  * needed. Only valid for dirs.
05208  *
05209  * Note that "." and ".." children MUST NOT BE returned.
05210  *
05211  * @param src
05212  *     The given source
05213  * @param child
05214  *     pointer to be filled with the given child. Undefined on error or OEF
05215  * @return
05216  *     1 on success, 0 if EOF (no more children), < 0 on error
05217  *      Error codes:
05218  *         ISO_FILE_ERROR
05219  *         ISO_NULL_POINTER
05220  *         ISO_FILE_NOT_OPENED
05221  *         ISO_FILE_IS_NOT_DIR
05222  *         ISO_OUT_OF_MEM
05223  *
05224  * @since 0.6.2
05225  */
05226 int iso_file_source_readdir(IsoFileSource *src, IsoFileSource **child);
05227 
05228 /**
05229  * Read the destination of a symlink. You don't need to open the file
05230  * to call this.
05231  *
05232  * @param src
05233  *     An IsoFileSource corresponding to a symbolic link.
05234  * @param buf
05235  *     Allocated buffer of at least bufsiz bytes.
05236  *     The destination string will be copied there, and it will be 0-terminated
05237  *     if the return value indicates success or ISO_RR_PATH_TOO_LONG.
05238  * @param bufsiz
05239  *     Maximum number of buf characters + 1. The string will be truncated if
05240  *     it is larger than bufsiz - 1 and ISO_RR_PATH_TOO_LONG. will be returned.
05241  * @return
05242  *     1 on success, < 0 on error
05243  *      Error codes:
05244  *         ISO_FILE_ERROR
05245  *         ISO_NULL_POINTER
05246  *         ISO_WRONG_ARG_VALUE -> if bufsiz <= 0
05247  *         ISO_FILE_IS_NOT_SYMLINK
05248  *         ISO_OUT_OF_MEM
05249  *         ISO_FILE_BAD_PATH
05250  *         ISO_FILE_DOESNT_EXIST
05251  *         ISO_RR_PATH_TOO_LONG (@since 1.0.6)
05252  *
05253  * @since 0.6.2
05254  */
05255 int iso_file_source_readlink(IsoFileSource *src, char *buf, size_t bufsiz);
05256 
05257 
05258 /**
05259  * Get the AAIP string with encoded ACL and xattr.
05260  * (Not to be confused with ECMA-119 Extended Attributes).
05261  * @param src        The file source object to be inquired.
05262  * @param aa_string  Returns a pointer to the AAIP string data. If no AAIP
05263  *                   string is available, *aa_string becomes NULL.
05264  *                   (See doc/susp_aaip_2_0.txt for the meaning of AAIP.) 
05265  *                   The caller is responsible for finally calling free()
05266  *                   on non-NULL results.
05267  * @param flag       Bitfield for control purposes
05268  *                   bit0= Transfer ownership of AAIP string data.
05269  *                         src will free the eventual cached data and might
05270  *                         not be able to produce it again.
05271  *                   bit1= No need to get ACL (but no guarantee of exclusion)
05272  *                   bit2= No need to get xattr (but no guarantee of exclusion)
05273  * @return           1 means success (*aa_string == NULL is possible)
05274  *                  <0 means failure and must b a valid libisofs error code
05275  *                     (e.g. ISO_FILE_ERROR if no better one can be found).
05276  * @since 0.6.14
05277  */
05278 int iso_file_source_get_aa_string(IsoFileSource *src,
05279                                   unsigned char **aa_string, int flag);
05280 
05281 /**
05282  * Get the filesystem for this source. No extra ref is added, so you
05283  * musn't unref the IsoFilesystem.
05284  *
05285  * @return
05286  *     The filesystem, NULL on error
05287  *
05288  * @since 0.6.2
05289  */
05290 IsoFilesystem* iso_file_source_get_filesystem(IsoFileSource *src);
05291 
05292 /**
05293  * Take a ref to the given IsoFilesystem
05294  *
05295  * @since 0.6.2
05296  */
05297 void iso_filesystem_ref(IsoFilesystem *fs);
05298 
05299 /**
05300  * Drop your ref to the given IsoFilesystem, evetually freeing associated
05301  * resources.
05302  *
05303  * @since 0.6.2
05304  */
05305 void iso_filesystem_unref(IsoFilesystem *fs);
05306 
05307 /**
05308  * Create a new IsoFilesystem to access a existent ISO image.
05309  *
05310  * @param src
05311  *      Data source to access data.
05312  * @param opts
05313  *      Image read options
05314  * @param msgid
05315  *      An image identifer, obtained with iso_image_get_msg_id(), used to
05316  *      associated messages issued by the filesystem implementation with an
05317  *      existent image. If you are not using this filesystem in relation with
05318  *      any image context, just use 0x1fffff as the value for this parameter.
05319  * @param fs
05320  *      Will be filled with a pointer to the filesystem that can be used
05321  *      to access image contents.
05322  * @param
05323  *      1 on success, < 0 on error
05324  *
05325  * @since 0.6.2
05326  */
05327 int iso_image_filesystem_new(IsoDataSource *src, IsoReadOpts *opts, int msgid,
05328                              IsoImageFilesystem **fs);
05329 
05330 /**
05331  * Get the volset identifier for an existent image. The returned string belong
05332  * to the IsoImageFilesystem and shouldn't be free() nor modified.
05333  *
05334  * @since 0.6.2
05335  */
05336 const char *iso_image_fs_get_volset_id(IsoImageFilesystem *fs);
05337 
05338 /**
05339  * Get the volume identifier for an existent image. The returned string belong
05340  * to the IsoImageFilesystem and shouldn't be free() nor modified.
05341  *
05342  * @since 0.6.2
05343  */
05344 const char *iso_image_fs_get_volume_id(IsoImageFilesystem *fs);
05345 
05346 /**
05347  * Get the publisher identifier for an existent image. The returned string
05348  * belong to the IsoImageFilesystem and shouldn't be free() nor modified.
05349  *
05350  * @since 0.6.2
05351  */
05352 const char *iso_image_fs_get_publisher_id(IsoImageFilesystem *fs);
05353 
05354 /**
05355  * Get the data preparer identifier for an existent image. The returned string
05356  * belong to the IsoImageFilesystem and shouldn't be free() nor modified.
05357  *
05358  * @since 0.6.2
05359  */
05360 const char *iso_image_fs_get_data_preparer_id(IsoImageFilesystem *fs);
05361 
05362 /**
05363  * Get the system identifier for an existent image. The returned string belong
05364  * to the IsoImageFilesystem and shouldn't be free() nor modified.
05365  *
05366  * @since 0.6.2
05367  */
05368 const char *iso_image_fs_get_system_id(IsoImageFilesystem *fs);
05369 
05370 /**
05371  * Get the application identifier for an existent image. The returned string
05372  * belong to the IsoImageFilesystem and shouldn't be free() nor modified.
05373  *
05374  * @since 0.6.2
05375  */
05376 const char *iso_image_fs_get_application_id(IsoImageFilesystem *fs);
05377 
05378 /**
05379  * Get the copyright file identifier for an existent image. The returned string
05380  * belong to the IsoImageFilesystem and shouldn't be free() nor modified.
05381  *
05382  * @since 0.6.2
05383  */
05384 const char *iso_image_fs_get_copyright_file_id(IsoImageFilesystem *fs);
05385 
05386 /**
05387  * Get the abstract file identifier for an existent image. The returned string
05388  * belong to the IsoImageFilesystem and shouldn't be free() nor modified.
05389  *
05390  * @since 0.6.2
05391  */
05392 const char *iso_image_fs_get_abstract_file_id(IsoImageFilesystem *fs);
05393 
05394 /**
05395  * Get the biblio file identifier for an existent image. The returned string
05396  * belong to the IsoImageFilesystem and shouldn't be free() nor modified.
05397  *
05398  * @since 0.6.2
05399  */
05400 const char *iso_image_fs_get_biblio_file_id(IsoImageFilesystem *fs);
05401 
05402 /**
05403  * Increment reference count of an IsoStream.
05404  *
05405  * @since 0.6.4
05406  */
05407 void iso_stream_ref(IsoStream *stream);
05408 
05409 /**
05410  * Decrement reference count of an IsoStream, and eventually free it if
05411  * refcount reach 0.
05412  *
05413  * @since 0.6.4
05414  */
05415 void iso_stream_unref(IsoStream *stream);
05416 
05417 /**
05418  * Opens the given stream. Remember to close the Stream before writing the
05419  * image.
05420  *
05421  * @return
05422  *     1 on success, 2 file greater than expected, 3 file smaller than
05423  *     expected, < 0 on error
05424  *
05425  * @since 0.6.4
05426  */
05427 int iso_stream_open(IsoStream *stream);
05428 
05429 /**
05430  * Close a previously openned IsoStream.
05431  *
05432  * @return
05433  *      1 on success, < 0 on error
05434  *
05435  * @since 0.6.4
05436  */
05437 int iso_stream_close(IsoStream *stream);
05438 
05439 /**
05440  * Get the size of a given stream. This function should always return the same
05441  * size, even if the underlying source size changes, unless you call
05442  * iso_stream_update_size().
05443  *
05444  * @return
05445  *      IsoStream size in bytes
05446  *
05447  * @since 0.6.4
05448  */
05449 off_t iso_stream_get_size(IsoStream *stream);
05450 
05451 /**
05452  * Attempts to read up to count bytes from the given stream into
05453  * the buffer starting at buf.
05454  *
05455  * The stream must be open() before calling this, and close() when no
05456  * more needed.
05457  *
05458  * @return
05459  *     number of bytes read, 0 if EOF, < 0 on error
05460  *
05461  * @since 0.6.4
05462  */
05463 int iso_stream_read(IsoStream *stream, void *buf, size_t count);
05464 
05465 /**
05466  * Whether the given IsoStream can be read several times, with the same
05467  * results.
05468  * For example, a regular file is repeatable, you can read it as many
05469  * times as you want. However, a pipe isn't.
05470  *
05471  * This function doesn't take into account if the file has been modified
05472  * between the two reads.
05473  *
05474  * @return
05475  *     1 if stream is repeatable, 0 if not, < 0 on error
05476  *
05477  * @since 0.6.4
05478  */
05479 int iso_stream_is_repeatable(IsoStream *stream);
05480 
05481 /**
05482  * Updates the size of the IsoStream with the current size of the
05483  * underlying source.
05484  *
05485  * @return
05486  *     1 if ok, < 0 on error (has to be a valid libisofs error code),
05487  *     0 if the IsoStream does not support this function.
05488  * @since 0.6.8
05489  */
05490 int iso_stream_update_size(IsoStream *stream);
05491 
05492 /**
05493  * Get an unique identifier for a given IsoStream.
05494  *
05495  * @since 0.6.4
05496  */
05497 void iso_stream_get_id(IsoStream *stream, unsigned int *fs_id, dev_t *dev_id,
05498                       ino_t *ino_id);
05499 
05500 /**
05501  * Try to get eventual source path string of a stream. Meaning and availability
05502  * of this string depends on the stream.class . Expect valid results with
05503  * types "fsrc" and "cout". Result formats are
05504  * fsrc: result of file_source_get_path()
05505  * cout: result of file_source_get_path() " " offset " " size 
05506  * @param stream
05507  *     The stream to be inquired.
05508  * @param flag
05509  *     Bitfield for control purposes, unused yet, submit 0
05510  * @return
05511  *     A copy of the path string. Apply free() when no longer needed.
05512  *     NULL if no path string is available.
05513  *
05514  * @since 0.6.18
05515  */
05516 char *iso_stream_get_source_path(IsoStream *stream, int flag);
05517 
05518 /**
05519  * Compare two streams whether they are based on the same input and will
05520  * produce the same output. If in any doubt, then this comparison will
05521  * indicate no match.
05522  *
05523  * @param s1
05524  *     The first stream to compare.
05525  * @param s2
05526  *     The second stream to compare.
05527  * @return
05528  *     -1 if s1 is smaller s2 , 0 if s1 matches s2 , 1 if s1 is larger s2
05529  * @param flag
05530  *     bit0= do not use s1->class->compare() even if available
05531  *           (e.g. because iso_stream_cmp_ino(0 is called as fallback
05532  *            from said stream->class->compare())
05533  *
05534  * @since 0.6.20
05535  */
05536 int iso_stream_cmp_ino(IsoStream *s1, IsoStream *s2, int flag);
05537 
05538 
05539 /**
05540  * Produce a copy of a stream. It must be possible to operate both stream
05541  * objects concurrently. The success of this function depends on the
05542  * existence of a IsoStream_Iface.clone_stream() method with the stream
05543  * and with its eventual subordinate streams. 
05544  * See iso_tree_clone() for a list of surely clonable built-in streams.
05545  * 
05546  * @param old_stream
05547  *     The existing stream object to be copied
05548  * @param new_stream
05549  *     Will return a pointer to the copy
05550  * @param flag
05551  *     Bitfield for control purposes. Submit 0 for now.
05552  * @return
05553  *     >0 means success
05554  *     ISO_STREAM_NO_CLONE is issued if no .clone_stream() exists
05555  *     other error return values < 0 may occur depending on kind of stream
05556  *
05557  * @since 1.0.2
05558  */
05559 int iso_stream_clone(IsoStream *old_stream, IsoStream **new_stream, int flag);
05560 
05561 
05562 /* --------------------------------- AAIP --------------------------------- */
05563 
05564 /**
05565  * Function to identify and manage AAIP strings as xinfo of IsoNode.
05566  *
05567  * An AAIP string contains the Attribute List with the xattr and ACL of a node
05568  * in the image tree. It is formatted according to libisofs specification
05569  * AAIP-2.0 and ready to be written into the System Use Area resp. Continuation
05570  * Area of a directory entry in an ISO image.
05571  *
05572  * Applications are not supposed to manipulate AAIP strings directly.
05573  * They should rather make use of the appropriate iso_node_get_* and
05574  * iso_node_set_* calls.
05575  *
05576  * AAIP represents ACLs as xattr with empty name and AAIP-specific binary
05577  * content. Local filesystems may represent ACLs as xattr with names like
05578  * "system.posix_acl_access". libisofs does not interpret those local
05579  * xattr representations of ACL directly but rather uses the ACL interface of
05580  * the local system. By default the local xattr representations of ACL will
05581  * not become part of the AAIP Attribute List via iso_local_get_attrs() and
05582  * not be attached to local files via iso_local_set_attrs().
05583  *
05584  * @since 0.6.14
05585  */
05586 int aaip_xinfo_func(void *data, int flag);
05587 
05588 /**
05589  * The iso_node_xinfo_cloner function which gets associated to aaip_xinfo_func
05590  * by iso_init() resp. iso_init_with_flag() via iso_node_xinfo_make_clonable().
05591  * @since 1.0.2
05592  */
05593 int aaip_xinfo_cloner(void *old_data, void **new_data, int flag);
05594 
05595 /**
05596  * Get the eventual ACLs which are associated with the node.
05597  * The result will be in "long" text form as of man acl resp. acl_to_text().
05598  * Call this function with flag bit15 to finally release the memory
05599  * occupied by an ACL inquiry.
05600  *
05601  * @param node
05602  *      The node that is to be inquired.
05603  * @param access_text
05604  *      Will return a pointer to the eventual "access" ACL text or NULL if it
05605  *      is not available and flag bit 4 is set.
05606  * @param default_text
05607  *      Will return a pointer to the eventual "default" ACL  or NULL if it
05608  *      is not available.
05609  *      (GNU/Linux directories can have a "default" ACL which influences
05610  *       the permissions of newly created files.)
05611  * @param flag
05612  *      Bitfield for control purposes
05613  *      bit4=  if no "access" ACL is available: return *access_text == NULL
05614  *             else:                       produce ACL from stat(2) permissions
05615  *      bit15= free memory and return 1 (node may be NULL)
05616  * @return
05617  *      2 *access_text was produced from stat(2) permissions
05618  *      1 *access_text was produced from ACL of node
05619  *      0 if flag bit4 is set and no ACL is available
05620  *      < 0 on error
05621  *
05622  * @since 0.6.14
05623  */
05624 int iso_node_get_acl_text(IsoNode *node,
05625                           char **access_text, char **default_text, int flag);
05626 
05627 
05628 /**
05629  * Set the ACLs of the given node to the lists in parameters access_text and
05630  * default_text or delete them.
05631  *
05632  * The stat(2) permission bits get updated according to the new "access" ACL if
05633  * neither bit1 of parameter flag is set nor parameter access_text is NULL.
05634  * Note that S_IRWXG permission bits correspond to ACL mask permissions
05635  * if a "mask::" entry exists in the ACL. Only if there is no "mask::" then
05636  * the "group::" entry corresponds to to S_IRWXG.
05637  * 
05638  * @param node
05639  *      The node that is to be manipulated.
05640  * @param access_text
05641  *      The text to be set into effect as "access" ACL. NULL will delete an
05642  *      eventually existing "access" ACL of the node.
05643  * @param default_text
05644  *      The text to be set into effect as "default" ACL. NULL will delete an
05645  *      eventually existing "default" ACL of the node.
05646  *      (GNU/Linux directories can have a "default" ACL which influences
05647  *       the permissions of newly created files.)
05648  * @param flag
05649  *      Bitfield for control purposes
05650  *      bit1=  ignore text parameters but rather update eventual "access" ACL
05651  *             to the stat(2) permissions of node. If no "access" ACL exists,
05652  *             then do nothing and return success.
05653  * @return
05654  *      > 0 success
05655  *      < 0 failure
05656  *
05657  * @since 0.6.14
05658  */
05659 int iso_node_set_acl_text(IsoNode *node,
05660                           char *access_text, char *default_text, int flag);
05661 
05662 /**
05663  * Like iso_node_get_permissions but reflecting ACL entry "group::" in S_IRWXG
05664  * rather than ACL entry "mask::". This is necessary if the permissions of a
05665  * node with ACL shall be restored to a filesystem without restoring the ACL.
05666  * The same mapping happens internally when the ACL of a node is deleted.
05667  * If the node has no ACL then the result is iso_node_get_permissions(node).
05668  * @param node
05669  *      The node that is to be inquired.
05670  * @return
05671  *      Permission bits as of stat(2)
05672  *
05673  * @since 0.6.14
05674  */
05675 mode_t iso_node_get_perms_wo_acl(const IsoNode *node);
05676 
05677 
05678 /**
05679  * Get the list of xattr which is associated with the node.
05680  * The resulting data may finally be disposed by a call to this function
05681  * with flag bit15 set, or its components may be freed one-by-one.
05682  * The following values are either NULL or malloc() memory:
05683  *   *names, *value_lengths, *values, (*names)[i], (*values)[i] 
05684  * with 0 <= i < *num_attrs.
05685  * It is allowed to replace or reallocate those memory items in order to
05686  * to manipulate the attribute list before submitting it to other calls.
05687  *
05688  * If enabled by flag bit0, this list possibly includes the ACLs of the node.
05689  * They are eventually encoded in a pair with empty name. It is not advisable
05690  * to alter the value or name of that pair. One may decide to erase both ACLs
05691  * by deleting this pair or to copy both ACLs by copying the content of this
05692  * pair to an empty named pair of another node.
05693  * For all other ACL purposes use iso_node_get_acl_text().
05694  *
05695  * @param node
05696  *      The node that is to be inquired.
05697  * @param num_attrs
05698  *      Will return the number of name-value pairs
05699  * @param names
05700  *      Will return an array of pointers to 0-terminated names
05701  * @param value_lengths
05702  *      Will return an arry with the lenghts of values
05703  * @param values
05704  *      Will return an array of pointers to strings of 8-bit bytes
05705  * @param flag
05706  *      Bitfield for control purposes
05707  *      bit0=  obtain eventual ACLs as attribute with empty name
05708  *      bit2=  with bit0: do not obtain attributes other than ACLs
05709  *      bit15= free memory (node may be NULL)
05710  * @return
05711  *      1 = ok (but *num_attrs may be 0)
05712  *    < 0 = error
05713  *
05714  * @since 0.6.14
05715  */
05716 int iso_node_get_attrs(IsoNode *node, size_t *num_attrs,
05717               char ***names, size_t **value_lengths, char ***values, int flag);
05718 
05719 
05720 /**
05721  * Obtain the value of a particular xattr name. Eventually make a copy of
05722  * that value and add a trailing 0 byte for caller convenience.
05723  * @param node
05724  *      The node that is to be inquired.
05725  * @param name
05726  *      The xattr name that shall be looked up.
05727  * @param value_length
05728  *      Will return the lenght of value
05729  * @param value
05730  *      Will return a string of 8-bit bytes. free() it when no longer needed.
05731  * @param flag
05732  *      Bitfield for control purposes, unused yet, submit 0
05733  * @return
05734  *      1= name found , 0= name not found , <0 indicates error
05735  *
05736  * @since 0.6.18
05737  */
05738 int iso_node_lookup_attr(IsoNode *node, char *name,
05739                          size_t *value_length, char **value, int flag);
05740 
05741 /**
05742  * Set the list of xattr which is associated with the node.
05743  * The data get copied so that you may dispose your input data afterwards.
05744  *
05745  * If enabled by flag bit0 then the submitted list of attributes will not only
05746  * overwrite xattr but also both eventual ACLs of the node. Eventual ACL in
05747  * the submitted list have to reside in an attribute with empty name.
05748  *
05749  * @param node
05750  *      The node that is to be manipulated.
05751  * @param num_attrs
05752  *      Number of attributes
05753  * @param names
05754  *      Array of pointers to 0 terminated name strings
05755  * @param value_lengths
05756  *      Array of byte lengths for each value
05757  * @param values
05758  *      Array of pointers to the value bytes
05759  * @param flag
05760  *      Bitfield for control purposes
05761  *      bit0= Do not maintain eventual existing ACL of the node.
05762  *            Set eventual new ACL from value of empty name.
05763  *      bit1= Do not clear the existing attribute list but merge it with
05764  *            the list given by this call.
05765  *            The given values override the values of their eventually existing
05766  *            names. If no xattr with a given name exists, then it will be
05767  *            added as new xattr. So this bit can be used to set a single
05768  *            xattr without inquiring any other xattr of the node.
05769  *      bit2= Delete the attributes with the given names
05770  *      bit3= Allow to affect non-user attributes.
05771  *            I.e. those with a non-empty name which does not begin by "user."
05772  *            (The empty name is always allowed and governed by bit0.) This
05773  *            deletes all previously existing attributes if not bit1 is set.
05774  * @return
05775  *      1 = ok
05776  *    < 0 = error
05777  *
05778  * @since 0.6.14
05779  */
05780 int iso_node_set_attrs(IsoNode *node, size_t num_attrs, char **names,
05781                        size_t *value_lengths, char **values, int flag);
05782 
05783 
05784 /* ----- This is an interface to ACL and xattr of the local filesystem ----- */
05785 
05786 /**
05787  * libisofs has an internal system dependent adapter to ACL and xattr
05788  * operations. For the sake of completeness and simplicity it exposes this
05789  * functionality to its applications which might want to get and set ACLs
05790  * from local files.
05791  */
05792 
05793 /**
05794  * Inquire whether local filesystem operations with ACL or xattr are enabled
05795  * inside libisofs. They may be disabled because of compile time decisions.
05796  * E.g. because the operating system does not support these features or
05797  * because libisofs has not yet an adapter to use them.
05798  * 
05799  * @param flag
05800  *      Bitfield for control purposes
05801  *           bit0= inquire availability of ACL
05802  *           bit1= inquire availability of xattr
05803  *           bit2 - bit7= Reserved for future types.
05804  *                        It is permissibile to set them to 1 already now.
05805  *           bit8 and higher: reserved, submit 0
05806  * @return
05807  *      Bitfield corresponding to flag. If bits are set, th
05808  *           bit0= ACL adapter is enabled
05809  *           bit1= xattr adapter is enabled
05810  *           bit2 - bit7= Reserved for future types.
05811  *           bit8 and higher: reserved, do not interpret these
05812  *
05813  * @since 1.1.6
05814  */
05815 int iso_local_attr_support(int flag);
05816 
05817 /**
05818  * Get an ACL of the given file in the local filesystem in long text form.
05819  *
05820  * @param disk_path
05821  *      Absolute path to the file
05822  * @param text
05823  *      Will return a pointer to the ACL text. If not NULL the text will be
05824  *      0 terminated and finally has to be disposed by a call to this function
05825  *      with bit15 set.
05826  * @param flag
05827  *      Bitfield for control purposes
05828  *           bit0=  get "default" ACL rather than "access" ACL
05829  *           bit4=  set *text = NULL and return 2
05830  *                  if the ACL matches st_mode permissions.
05831  *           bit5=  in case of symbolic link: inquire link target
05832  *           bit15= free text and return 1
05833  * @return
05834  *        1 ok 
05835  *        2 ok, trivial ACL found while bit4 is set, *text is NULL 
05836  *        0 no ACL manipulation adapter available / ACL not supported on fs
05837  *       -1 failure of system ACL service (see errno)
05838  *       -2 attempt to inquire ACL of a symbolic link without bit4 or bit5
05839  *          resp. with no suitable link target
05840  *
05841  * @since 0.6.14
05842  */
05843 int iso_local_get_acl_text(char *disk_path, char **text, int flag);
05844 
05845 
05846 /**
05847  * Set the ACL of the given file in the local filesystem to a given list
05848  * in long text form.
05849  *
05850  * @param disk_path
05851  *      Absolute path to the file
05852  * @param text
05853  *      The input text (0 terminated, ACL long text form)
05854  * @param flag
05855  *      Bitfield for control purposes
05856  *           bit0=  set "default" ACL rather than "access" ACL
05857  *           bit5=  in case of symbolic link: manipulate link target
05858  * @return
05859  *      > 0 ok
05860  *        0 no ACL manipulation adapter available for desired ACL type
05861  *       -1 failure of system ACL service (see errno)
05862  *       -2 attempt to manipulate ACL of a symbolic link without bit5
05863  *          resp. with no suitable link target
05864  *
05865  * @since 0.6.14
05866  */
05867 int iso_local_set_acl_text(char *disk_path, char *text, int flag);
05868 
05869 
05870 /**
05871  * Obtain permissions of a file in the local filesystem which shall reflect
05872  * ACL entry "group::" in S_IRWXG rather than ACL entry "mask::". This is
05873  * necessary if the permissions of a disk file with ACL shall be copied to
05874  * an object which has no ACL.
05875  * @param disk_path
05876  *      Absolute path to the local file which may have an "access" ACL or not.
05877  * @param flag
05878  *      Bitfield for control purposes
05879  *           bit5=  in case of symbolic link: inquire link target
05880  * @param st_mode
05881  *      Returns permission bits as of stat(2)
05882  * @return
05883  *      1 success
05884  *     -1 failure of lstat() resp. stat() (see errno)
05885  *
05886  * @since 0.6.14
05887  */
05888 int iso_local_get_perms_wo_acl(char *disk_path, mode_t *st_mode, int flag);
05889 
05890 
05891 /**
05892  * Get xattr and non-trivial ACLs of the given file in the local filesystem.
05893  * The resulting data has finally to be disposed by a call to this function
05894  * with flag bit15 set.
05895  *
05896  * Eventual ACLs will get encoded as attribute pair with empty name if this is
05897  * enabled by flag bit0. An ACL which simply replects stat(2) permissions
05898  * will not be put into the result.
05899  *
05900  * @param disk_path
05901  *      Absolute path to the file
05902  * @param num_attrs
05903  *      Will return the number of name-value pairs
05904  * @param names
05905  *      Will return an array of pointers to 0-terminated names
05906  * @param value_lengths
05907  *      Will return an arry with the lenghts of values
05908  * @param values
05909  *      Will return an array of pointers to 8-bit values
05910  * @param flag
05911  *      Bitfield for control purposes
05912  *      bit0=  obtain eventual ACLs as attribute with empty name
05913  *      bit2=  do not obtain attributes other than ACLs
05914  *      bit3=  do not ignore eventual non-user attributes.
05915  *             I.e. those with a name which does not begin by "user."
05916  *      bit5=  in case of symbolic link: inquire link target
05917  *      bit15= free memory
05918  * @return
05919  *        1 ok
05920  *      < 0 failure
05921  *
05922  * @since 0.6.14
05923  */
05924 int iso_local_get_attrs(char *disk_path, size_t *num_attrs, char ***names,
05925                         size_t **value_lengths, char ***values, int flag);
05926 
05927 
05928 /**
05929  * Attach a list of xattr and ACLs to the given file in the local filesystem.
05930  *
05931  * Eventual ACLs have to be encoded as attribute pair with empty name.
05932  *
05933  * @param disk_path
05934  *      Absolute path to the file
05935  * @param num_attrs
05936  *      Number of attributes
05937  * @param names
05938  *      Array of pointers to 0 terminated name strings
05939  * @param value_lengths
05940  *      Array of byte lengths for each attribute payload
05941  * @param values
05942  *      Array of pointers to the attribute payload bytes
05943  * @param flag
05944  *      Bitfield for control purposes
05945  *      bit0=  do not attach ACLs from an eventual attribute with empty name
05946  *      bit3=  do not ignore eventual non-user attributes.
05947  *             I.e. those with a name which does not begin by "user."
05948  *      bit5=  in case of symbolic link: manipulate link target
05949  *      bit6=  @since 1.1.6
05950                tolerate inappropriate presence or absence of
05951  *             directory "default" ACL
05952  * @return
05953  *      1 = ok 
05954  *    < 0 = error
05955  *
05956  * @since 0.6.14
05957  */
05958 int iso_local_set_attrs(char *disk_path, size_t num_attrs, char **names,
05959                         size_t *value_lengths, char **values, int flag);
05960 
05961 
05962 /* Default in case that the compile environment has no macro PATH_MAX.
05963 */
05964 #define Libisofs_default_path_maX 4096
05965 
05966 
05967 /* --------------------------- Filters in General -------------------------- */
05968 
05969 /*
05970  * A filter is an IsoStream which uses another IsoStream as input. It gets
05971  * attached to an IsoFile by specialized calls iso_file_add_*_filter() which
05972  * replace its current IsoStream by the filter stream which takes over the
05973  * current IsoStream as input.
05974  * The consequences are:
05975  *   iso_file_get_stream() will return the filter stream.
05976  *   iso_stream_get_size() will return the (cached) size of the filtered data,
05977  *   iso_stream_open()     will start eventual child processes,
05978  *   iso_stream_close()    will kill eventual child processes,
05979  *   iso_stream_read()     will return filtered data. E.g. as data file content
05980  *                         during ISO image generation.
05981  *
05982  * There are external filters which run child processes
05983  *   iso_file_add_external_filter()
05984  * and internal filters
05985  *   iso_file_add_zisofs_filter()
05986  *   iso_file_add_gzip_filter()
05987  * which may or may not be available depending on compile time settings and
05988  * installed software packages like libz.
05989  *
05990  * During image generation filters get not in effect if the original IsoStream
05991  * is an "fsrc" stream based on a file in the loaded ISO image and if the
05992  * image generation type is set to 1 by iso_write_opts_set_appendable().
05993  */
05994 
05995 /**
05996  * Delete the top filter stream from a data file. This is the most recent one
05997  * which was added by iso_file_add_*_filter().
05998  * Caution: One should not do this while the IsoStream of the file is opened.
05999  *          For now there is no general way to determine this state.
06000  *          Filter stream implementations are urged to eventually call .close()
06001  *          inside method .free() . This will close the input stream too.
06002  * @param file
06003  *      The data file node which shall get rid of one layer of content
06004  *      filtering.
06005  * @param flag
06006  *      Bitfield for control purposes, unused yet, submit 0.
06007  * @return
06008  *      1 on success, 0 if no filter was present
06009  *      <0 on error
06010  *
06011  * @since 0.6.18
06012  */
06013 int iso_file_remove_filter(IsoFile *file, int flag);
06014 
06015 /**
06016  * Obtain the eventual input stream of a filter stream.
06017  * @param stream
06018  *      The eventual filter stream to be inquired.
06019  * @param flag
06020  *      Bitfield for control purposes. Submit 0 for now.
06021  * @return
06022  *      The input stream, if one exists. Elsewise NULL.
06023  *      No extra reference to the stream is taken by this call.
06024  * 
06025  * @since 0.6.18
06026  */    
06027 IsoStream *iso_stream_get_input_stream(IsoStream *stream, int flag);
06028 
06029 
06030 /* ---------------------------- External Filters --------------------------- */
06031 
06032 /**
06033  * Representation of an external program that shall serve as filter for
06034  * an IsoStream. This object may be shared among many IsoStream objects.
06035  * It is to be created and disposed by the application.
06036  *
06037  * The filter will act as proxy between the original IsoStream of an IsoFile.
06038  * Up to completed image generation it will be run at least twice: 
06039  * for IsoStream.class.get_size() and for .open() with subsequent .read().
06040  * So the original IsoStream has to return 1 by its .class.is_repeatable().
06041  * The filter program has to be repeateable too. I.e. it must produce the same
06042  * output on the same input.
06043  *
06044  * @since 0.6.18
06045  */
06046 struct iso_external_filter_command
06047 {
06048     /* Will indicate future extensions. It has to be 0 for now. */
06049     int version;
06050 
06051     /* Tells how many IsoStream objects depend on this command object.
06052      * One may only dispose an IsoExternalFilterCommand when this count is 0.
06053      * Initially this value has to be 0.
06054      */
06055     int refcount;
06056 
06057     /* An optional instance id.
06058      * Set to empty text if no individual name for this object is intended.
06059      */
06060     char *name;
06061 
06062     /* Absolute local filesystem path to the executable program. */
06063     char *path;
06064 
06065     /* Tells the number of arguments. */
06066     int argc;
06067 
06068     /* NULL terminated list suitable for system call execv(3).
06069      * I.e. argv[0] points to the alleged program name,
06070      *      argv[1] to argv[argc] point to program arguments (if argc > 0)
06071      *      argv[argc+1] is NULL
06072      */
06073     char **argv;
06074 
06075     /* A bit field which controls behavior variations:
06076      * bit0= Do not install filter if the input has size 0.
06077      * bit1= Do not install filter if the output is not smaller than the input.
06078      * bit2= Do not install filter if the number of output blocks is
06079      *       not smaller than the number of input blocks. Block size is 2048.
06080      *       Assume that non-empty input yields non-empty output and thus do
06081      *       not attempt to attach a filter to files smaller than 2049 bytes.
06082      * bit3= suffix removed rather than added.
06083      *       (Removal and adding suffixes is the task of the application.
06084      *        This behavior bit serves only as reminder for the application.)
06085      */
06086     int behavior;
06087 
06088     /* The eventual suffix which is supposed to be added to the IsoFile name
06089      * resp. to be removed from the name.
06090      * (This is to be done by the application, not by calls
06091      *  iso_file_add_external_filter() or iso_file_remove_filter().
06092      *  The value recorded here serves only as reminder for the application.)
06093      */
06094     char *suffix;
06095 };
06096 
06097 typedef struct iso_external_filter_command IsoExternalFilterCommand;
06098 
06099 /**
06100  * Install an external filter command on top of the content stream of a data
06101  * file. The filter process must be repeatable. It will be run once by this
06102  * call in order to cache the output size.
06103  * @param file
06104  *      The data file node which shall show filtered content.
06105  * @param cmd
06106  *      The external program and its arguments which shall do the filtering.
06107  * @param flag
06108  *      Bitfield for control purposes, unused yet, submit 0.
06109  * @return
06110  *      1 on success, 2 if filter installation revoked (e.g. cmd.behavior bit1)
06111  *      <0 on error
06112  *
06113  * @since 0.6.18
06114  */
06115 int iso_file_add_external_filter(IsoFile *file, IsoExternalFilterCommand *cmd,
06116                                  int flag);
06117 
06118 /**
06119  * Obtain the IsoExternalFilterCommand which is eventually associated with the
06120  * given stream. (Typically obtained from an IsoFile by iso_file_get_stream()
06121  * or from an IsoStream by iso_stream_get_input_stream()).
06122  * @param stream
06123  *      The stream to be inquired.
06124  * @param cmd
06125  *      Will return the external IsoExternalFilterCommand. Valid only if
06126  *      the call returns 1. This does not increment cmd->refcount.
06127  * @param flag
06128  *      Bitfield for control purposes, unused yet, submit 0.
06129  * @return
06130  *      1 on success, 0 if the stream is not an external filter
06131  *      <0 on error
06132  *
06133  * @since 0.6.18
06134  */
06135 int iso_stream_get_external_filter(IsoStream *stream,
06136                                    IsoExternalFilterCommand **cmd, int flag);
06137 
06138 
06139 /* ---------------------------- Internal Filters --------------------------- */
06140 
06141 
06142 /**
06143  * Install a zisofs filter on top of the content stream of a data file.
06144  * zisofs is a compression format which is decompressed by some Linux kernels.
06145  * See also doc/zisofs_format.txt .
06146  * The filter will not be installed if its output size is not smaller than
06147  * the size of the input stream.
06148  * This is only enabled if the use of libz was enabled at compile time.
06149  * @param file
06150  *      The data file node which shall show filtered content.
06151  * @param flag
06152  *      Bitfield for control purposes
06153  *      bit0= Do not install filter if the number of output blocks is
06154  *            not smaller than the number of input blocks. Block size is 2048.
06155  *      bit1= Install a decompression filter rather than one for compression.
06156  *      bit2= Only inquire availability of zisofs filtering. file may be NULL.
06157  *            If available return 2, else return error.
06158  *      bit3= is reserved for internal use and will be forced to 0
06159  * @return
06160  *      1 on success, 2 if filter available but installation revoked
06161  *      <0 on error, e.g. ISO_ZLIB_NOT_ENABLED
06162  *
06163  * @since 0.6.18
06164  */
06165 int iso_file_add_zisofs_filter(IsoFile *file, int flag);
06166 
06167 /**
06168  * Inquire the number of zisofs compression and uncompression filters which
06169  * are in use.
06170  * @param ziso_count
06171  *      Will return the number of currently installed compression filters.
06172  * @param osiz_count
06173  *      Will return the number of currently installed uncompression filters.
06174  * @param flag
06175  *      Bitfield for control purposes, unused yet, submit 0
06176  * @return
06177  *      1 on success, <0 on error
06178  *
06179  * @since 0.6.18
06180  */
06181 int iso_zisofs_get_refcounts(off_t *ziso_count, off_t *osiz_count, int flag);
06182 
06183 
06184 /**
06185  * Parameter set for iso_zisofs_set_params().
06186  *
06187  * @since 0.6.18
06188  */
06189 struct iso_zisofs_ctrl {
06190 
06191     /* Set to 0 for this version of the structure */
06192     int version;
06193 
06194     /* Compression level for zlib function compress2(). From <zlib.h>:
06195      *  "between 0 and 9:
06196      *   1 gives best speed, 9 gives best compression, 0 gives no compression"
06197      * Default is 6.
06198      */
06199     int compression_level;
06200 
06201     /* Log2 of the block size for compression filters. Allowed values are:
06202      *   15 = 32 kiB ,  16 = 64 kiB ,  17 = 128 kiB
06203      */
06204     uint8_t block_size_log2;
06205 
06206 };
06207 
06208 /**
06209  * Set the global parameters for zisofs filtering.
06210  * This is only allowed while no zisofs compression filters are installed.
06211  * i.e. ziso_count returned by iso_zisofs_get_refcounts() has to be 0.
06212  * @param params
06213  *      Pointer to a structure with the intended settings.
06214  * @param flag
06215  *      Bitfield for control purposes, unused yet, submit 0
06216  * @return
06217  *      1 on success, <0 on error
06218  *
06219  * @since 0.6.18
06220  */
06221 int iso_zisofs_set_params(struct iso_zisofs_ctrl *params, int flag);
06222 
06223 /**
06224  * Get the current global parameters for zisofs filtering.
06225  * @param params
06226  *      Pointer to a caller provided structure which shall take the settings.
06227  * @param flag
06228  *      Bitfield for control purposes, unused yet, submit 0
06229  * @return
06230  *      1 on success, <0 on error
06231  *
06232  * @since 0.6.18
06233  */
06234 int iso_zisofs_get_params(struct iso_zisofs_ctrl *params, int flag);
06235 
06236 
06237 /**
06238  * Check for the given node or for its subtree whether the data file content
06239  * effectively bears zisofs file headers and eventually mark the outcome
06240  * by an xinfo data record if not already marked by a zisofs compressor filter.
06241  * This does not install any filter but only a hint for image generation
06242  * that the already compressed files shall get written with zisofs ZF entries.
06243  * Use this if you insert the compressed reults of program mkzftree from disk
06244  * into the image.
06245  * @param node
06246  *      The node which shall be checked and eventually marked.
06247  * @param flag
06248  *      Bitfield for control purposes, unused yet, submit 0
06249  *      bit0= prepare for a run with iso_write_opts_set_appendable(,1).
06250  *            Take into account that files from the imported image
06251  *            do not get their content filtered.
06252  *      bit1= permission to overwrite existing zisofs_zf_info
06253  *      bit2= if no zisofs header is found:
06254  *            create xinfo with parameters which indicate no zisofs
06255  *      bit3= no tree recursion if node is a directory
06256  *      bit4= skip files which stem from the imported image
06257  * @return
06258  *      0= no zisofs data found
06259  *      1= zf xinfo added
06260  *      2= found existing zf xinfo and flag bit1 was not set
06261  *      3= both encountered: 1 and 2
06262  *      <0 means error
06263  *
06264  * @since 0.6.18
06265  */
06266 int iso_node_zf_by_magic(IsoNode *node, int flag);
06267 
06268 
06269 /**
06270  * Install a gzip or gunzip filter on top of the content stream of a data file.
06271  * gzip is a compression format which is used by programs gzip and gunzip.
06272  * The filter will not be installed if its output size is not smaller than
06273  * the size of the input stream.
06274  * This is only enabled if the use of libz was enabled at compile time.
06275  * @param file
06276  *      The data file node which shall show filtered content.
06277  * @param flag
06278  *      Bitfield for control purposes
06279  *      bit0= Do not install filter if the number of output blocks is
06280  *            not smaller than the number of input blocks. Block size is 2048.
06281  *      bit1= Install a decompression filter rather than one for compression.
06282  *      bit2= Only inquire availability of gzip filtering. file may be NULL.
06283  *            If available return 2, else return error.
06284  *      bit3= is reserved for internal use and will be forced to 0
06285  * @return
06286  *      1 on success, 2 if filter available but installation revoked
06287  *      <0 on error, e.g. ISO_ZLIB_NOT_ENABLED
06288  *
06289  * @since 0.6.18
06290  */
06291 int iso_file_add_gzip_filter(IsoFile *file, int flag);
06292 
06293 
06294 /**
06295  * Inquire the number of gzip compression and uncompression filters which
06296  * are in use.
06297  * @param gzip_count
06298  *      Will return the number of currently installed compression filters.
06299  * @param gunzip_count
06300  *      Will return the number of currently installed uncompression filters.
06301  * @param flag
06302  *      Bitfield for control purposes, unused yet, submit 0
06303  * @return
06304  *      1 on success, <0 on error
06305  *
06306  * @since 0.6.18
06307  */
06308 int iso_gzip_get_refcounts(off_t *gzip_count, off_t *gunzip_count, int flag);
06309 
06310 
06311 /* ---------------------------- MD5 Checksums --------------------------- */
06312 
06313 /* Production and loading of MD5 checksums is controlled by calls
06314    iso_write_opts_set_record_md5() and iso_read_opts_set_no_md5().
06315    For data representation details see doc/checksums.txt .
06316 */
06317 
06318 /**
06319  * Eventually obtain the recorded MD5 checksum of the session which was
06320  * loaded as ISO image. Such a checksum may be stored together with others
06321  * in a contiguous array at the end of the session. The session checksum
06322  * covers the data blocks from address start_lba to address end_lba - 1.
06323  * It does not cover the recorded array of md5 checksums.
06324  * Layout, size, and position of the checksum array is recorded in the xattr
06325  * "isofs.ca" of the session root node.
06326  * @param image
06327  *      The image to inquire
06328  * @param start_lba
06329  *      Eventually returns the first block address covered by md5
06330  * @param end_lba
06331  *      Eventually returns the first block address not covered by md5 any more
06332  * @param md5
06333  *      Eventually returns 16 byte of MD5 checksum 
06334  * @param flag
06335  *      Bitfield for control purposes, unused yet, submit 0
06336  * @return
06337  *      1= md5 found , 0= no md5 available , <0 indicates error
06338  *
06339  * @since 0.6.22
06340  */
06341 int iso_image_get_session_md5(IsoImage *image, uint32_t *start_lba,
06342                               uint32_t *end_lba, char md5[16], int flag);
06343 
06344 /**
06345  * Eventually obtain the recorded MD5 checksum of a data file from the loaded
06346  * ISO image. Such a checksum may be stored with others in a contiguous
06347  * array at the end of the loaded session. The data file eventually has an
06348  * xattr "isofs.cx" which gives the index in that array.
06349  * @param image
06350  *      The image from which file stems.
06351  * @param file
06352  *      The file object to inquire
06353  * @param md5
06354  *      Eventually returns 16 byte of MD5 checksum 
06355  * @param flag
06356  *      Bitfield for control purposes
06357  *      bit0= only determine return value, do not touch parameter md5
06358  * @return
06359  *      1= md5 found , 0= no md5 available , <0 indicates error
06360  *
06361  * @since 0.6.22
06362  */
06363 int iso_file_get_md5(IsoImage *image, IsoFile *file, char md5[16], int flag);
06364 
06365 /**
06366  * Read the content of an IsoFile object, compute its MD5 and attach it to
06367  * the IsoFile. It can then be inquired by iso_file_get_md5() and will get
06368  * written into the next session if this is enabled at write time and if the
06369  * image write process does not compute an MD5 from content which it copies.
06370  * So this call can be used to equip nodes from the old image with checksums
06371  * or to make available checksums of newly added files before the session gets
06372  * written.
06373  * @param file
06374  *      The file object to read data from and to which to attach the checksum.
06375  *      If the file is from the imported image, then its most original stream
06376  *      will be checksummed. Else the eventual filter streams will get into
06377  *      effect.
06378  * @param flag
06379  *      Bitfield for control purposes. Unused yet. Submit 0.
06380  * @return
06381  *      1= ok, MD5 is computed and attached , <0 indicates error
06382  *
06383  * @since 0.6.22
06384  */
06385 int iso_file_make_md5(IsoFile *file, int flag);
06386 
06387 /**
06388  * Check a data block whether it is a libisofs session checksum tag and
06389  * eventually obtain its recorded parameters. These tags get written after
06390  * volume descriptors, directory tree and checksum array and can be detected
06391  * without loading the image tree.
06392  * One may start reading and computing MD5 at the suspected image session
06393  * start and look out for a session tag on the fly. See doc/checksum.txt .
06394  * @param data
06395  *      A complete and aligned data block read from an ISO image session.
06396  * @param tag_type
06397  *      0= no tag
06398  *      1= session tag
06399  *      2= superblock tag
06400  *      3= tree tag
06401  *      4= relocated 64 kB superblock tag (at LBA 0 of overwriteable media)
06402  * @param pos
06403  *      Returns the LBA where the tag supposes itself to be stored.
06404  *      If this does not match the data block LBA then the tag might be
06405  *      image data payload and should be ignored for image checksumming.
06406  * @param range_start
06407  *      Returns the block address where the session is supposed to start.
06408  *      If this does not match the session start on media then the image
06409  *      volume descriptors have been been relocated.
06410  *      A proper checksum will only emerge if computing started at range_start.
06411  * @param range_size
06412  *      Returns the number of blocks beginning at range_start which are
06413  *      covered by parameter md5.
06414  * @param next_tag
06415  *      Returns the predicted block address of the next tag.
06416  *      next_tag is valid only if not 0 and only with return values 2, 3, 4.
06417  *      With tag types 2 and 3, reading shall go on sequentially and the MD5
06418  *      computation shall continue up to that address.
06419  *      With tag type 4, reading shall resume either at LBA 32 for the first
06420  *      session or at the given address for the session which is to be loaded
06421  *      by default. In both cases the MD5 computation shall be re-started from
06422  *      scratch.
06423  * @param md5
06424  *      Returns 16 byte of MD5 checksum.
06425  * @param flag
06426  *      Bitfield for control purposes:
06427  *      bit0-bit7= tag type being looked for
06428  *                 0= any checksum tag
06429  *                 1= session tag
06430  *                 2= superblock tag
06431  *                 3= tree tag
06432  *                 4= relocated superblock tag
06433  * @return
06434  *      0= not a checksum tag, return parameters are invalid
06435  *      1= checksum tag found, return parameters are valid
06436  *     <0= error 
06437  *         (return parameters are valid with error ISO_MD5_AREA_CORRUPTED
06438  *          but not trustworthy because the tag seems corrupted)
06439  *
06440  * @since 0.6.22
06441  */
06442 int iso_util_decode_md5_tag(char data[2048], int *tag_type, uint32_t *pos,
06443                             uint32_t *range_start, uint32_t *range_size,
06444                             uint32_t *next_tag, char md5[16], int flag);
06445 
06446 
06447 /* The following functions allow to do own MD5 computations. E.g for
06448    comparing the result with a recorded checksum.
06449 */
06450 /**
06451  * Create a MD5 computation context and hand out an opaque handle.
06452  *
06453  * @param md5_context
06454  *      Returns the opaque handle. Submitted *md5_context must be NULL or
06455  *      point to freeable memory.
06456  * @return
06457  *      1= success , <0 indicates error
06458  *
06459  * @since 0.6.22
06460  */
06461 int iso_md5_start(void **md5_context);
06462 
06463 /**
06464  * Advance the computation of a MD5 checksum by a chunk of data bytes.
06465  *
06466  * @param md5_context
06467  *      An opaque handle once returned by iso_md5_start() or iso_md5_clone().
06468  * @param data
06469  *      The bytes which shall be processed into to the checksum.
06470  * @param datalen
06471  *      The number of bytes to be processed.
06472  * @return
06473  *      1= success , <0 indicates error
06474  *
06475  * @since 0.6.22
06476  */
06477 int iso_md5_compute(void *md5_context, char *data, int datalen);
06478 
06479 /**     
06480  * Create a MD5 computation context as clone of an existing one. One may call
06481  * iso_md5_clone(old, &new, 0) and then iso_md5_end(&new, result, 0) in order
06482  * to obtain an intermediate MD5 sum before the computation goes on.
06483  * 
06484  * @param old_md5_context
06485  *      An opaque handle once returned by iso_md5_start() or iso_md5_clone().
06486  * @param new_md5_context
06487  *      Returns the opaque handle to the new MD5 context. Submitted
06488  *      *md5_context must be NULL or point to freeable memory.
06489  * @return
06490  *      1= success , <0 indicates error
06491  *
06492  * @since 0.6.22
06493  */
06494 int iso_md5_clone(void *old_md5_context, void **new_md5_context);
06495 
06496 /**
06497  * Obtain the MD5 checksum from a MD5 computation context and dispose this
06498  * context. (If you want to keep the context then call iso_md5_clone() and
06499  * apply iso_md5_end() to the clone.)
06500  *
06501  * @param md5_context
06502  *      A pointer to an opaque handle once returned by iso_md5_start() or
06503  *      iso_md5_clone(). *md5_context will be set to NULL in this call.
06504  * @param result
06505  *      Gets filled with the 16 bytes of MD5 checksum.
06506  * @return
06507  *      1= success , <0 indicates error
06508  *
06509  * @since 0.6.22
06510  */
06511 int iso_md5_end(void **md5_context, char result[16]);
06512 
06513 /**
06514  * Inquire whether two MD5 checksums match. (This is trivial but such a call
06515  * is convenient and completes the interface.)
06516  * @param first_md5
06517  *      A MD5 byte string as returned by iso_md5_end()
06518  * @param second_md5
06519  *      A MD5 byte string as returned by iso_md5_end()
06520  * @return
06521  *      1= match , 0= mismatch
06522  *
06523  * @since 0.6.22
06524  */
06525 int iso_md5_match(char first_md5[16], char second_md5[16]);
06526 
06527 
06528 /************ Error codes and return values for libisofs ********************/
06529 
06530 /** successfully execution */
06531 #define ISO_SUCCESS                     1
06532 
06533 /**
06534  * special return value, it could be or not an error depending on the
06535  * context.
06536  */
06537 #define ISO_NONE                        0
06538 
06539 /** Operation canceled (FAILURE,HIGH, -1) */
06540 #define ISO_CANCELED                    0xE830FFFF
06541 
06542 /** Unknown or unexpected fatal error (FATAL,HIGH, -2) */
06543 #define ISO_FATAL_ERROR                 0xF030FFFE
06544 
06545 /** Unknown or unexpected error (FAILURE,HIGH, -3) */
06546 #define ISO_ERROR                       0xE830FFFD
06547 
06548 /** Internal programming error. Please report this bug (FATAL,HIGH, -4) */
06549 #define ISO_ASSERT_FAILURE              0xF030FFFC
06550 
06551 /**
06552  * NULL pointer as value for an arg. that doesn't allow NULL (FAILURE,HIGH, -5)
06553  */
06554 #define ISO_NULL_POINTER                0xE830FFFB
06555 
06556 /** Memory allocation error (FATAL,HIGH, -6) */
06557 #define ISO_OUT_OF_MEM                  0xF030FFFA
06558 
06559 /** Interrupted by a signal (FATAL,HIGH, -7) */
06560 #define ISO_INTERRUPTED                 0xF030FFF9
06561 
06562 /** Invalid parameter value (FAILURE,HIGH, -8) */
06563 #define ISO_WRONG_ARG_VALUE             0xE830FFF8
06564 
06565 /** Can't create a needed thread (FATAL,HIGH, -9) */
06566 #define ISO_THREAD_ERROR                0xF030FFF7
06567 
06568 /** Write error (FAILURE,HIGH, -10) */
06569 #define ISO_WRITE_ERROR                 0xE830FFF6
06570 
06571 /** Buffer read error (FAILURE,HIGH, -11) */
06572 #define ISO_BUF_READ_ERROR              0xE830FFF5
06573 
06574 /** Trying to add to a dir a node already added to a dir (FAILURE,HIGH, -64) */
06575 #define ISO_NODE_ALREADY_ADDED          0xE830FFC0
06576 
06577 /** Node with same name already exists (FAILURE,HIGH, -65) */
06578 #define ISO_NODE_NAME_NOT_UNIQUE        0xE830FFBF
06579 
06580 /** Trying to remove a node that was not added to dir (FAILURE,HIGH, -65) */
06581 #define ISO_NODE_NOT_ADDED_TO_DIR       0xE830FFBE
06582 
06583 /** A requested node does not exist  (FAILURE,HIGH, -66) */
06584 #define ISO_NODE_DOESNT_EXIST           0xE830FFBD
06585 
06586 /**
06587  * Try to set the boot image of an already bootable image (FAILURE,HIGH, -67)
06588  */
06589 #define ISO_IMAGE_ALREADY_BOOTABLE      0xE830FFBC
06590 
06591 /** Trying to use an invalid file as boot image (FAILURE,HIGH, -68) */
06592 #define ISO_BOOT_IMAGE_NOT_VALID        0xE830FFBB
06593 
06594 /** Too many boot images (FAILURE,HIGH, -69) */
06595 #define ISO_BOOT_IMAGE_OVERFLOW         0xE830FFBA
06596 
06597 /** No boot catalog created yet ((FAILURE,HIGH, -70) */ /* @since 0.6.34 */
06598 #define ISO_BOOT_NO_CATALOG             0xE830FFB9
06599 
06600 
06601 /**
06602  * Error on file operation (FAILURE,HIGH, -128)
06603  * (take a look at more specified error codes below)
06604  */
06605 #define ISO_FILE_ERROR                  0xE830FF80
06606 
06607 /** Trying to open an already opened file (FAILURE,HIGH, -129) */
06608 #define ISO_FILE_ALREADY_OPENED         0xE830FF7F
06609 
06610 /* @deprecated use ISO_FILE_ALREADY_OPENED instead */
06611 #define ISO_FILE_ALREADY_OPENNED        0xE830FF7F
06612 
06613 /** Access to file is not allowed (FAILURE,HIGH, -130) */
06614 #define ISO_FILE_ACCESS_DENIED          0xE830FF7E
06615 
06616 /** Incorrect path to file (FAILURE,HIGH, -131) */
06617 #define ISO_FILE_BAD_PATH               0xE830FF7D
06618 
06619 /** The file does not exist in the filesystem (FAILURE,HIGH, -132) */
06620 #define ISO_FILE_DOESNT_EXIST           0xE830FF7C
06621 
06622 /** Trying to read or close a file not openned (FAILURE,HIGH, -133) */
06623 #define ISO_FILE_NOT_OPENED             0xE830FF7B
06624 
06625 /* @deprecated use ISO_FILE_NOT_OPENED instead */
06626 #define ISO_FILE_NOT_OPENNED            ISO_FILE_NOT_OPENED
06627 
06628 /** Directory used where no dir is expected (FAILURE,HIGH, -134) */
06629 #define ISO_FILE_IS_DIR                 0xE830FF7A
06630 
06631 /** Read error (FAILURE,HIGH, -135) */
06632 #define ISO_FILE_READ_ERROR             0xE830FF79
06633 
06634 /** Not dir used where a dir is expected (FAILURE,HIGH, -136) */
06635 #define ISO_FILE_IS_NOT_DIR             0xE830FF78
06636 
06637 /** Not symlink used where a symlink is expected (FAILURE,HIGH, -137) */
06638 #define ISO_FILE_IS_NOT_SYMLINK         0xE830FF77
06639 
06640 /** Can't seek to specified location (FAILURE,HIGH, -138) */
06641 #define ISO_FILE_SEEK_ERROR             0xE830FF76
06642 
06643 /** File not supported in ECMA-119 tree and thus ignored (WARNING,MEDIUM, -139) */
06644 #define ISO_FILE_IGNORED                0xD020FF75
06645 
06646 /* A file is bigger than supported by used standard  (WARNING,MEDIUM, -140) */
06647 #define ISO_FILE_TOO_BIG                0xD020FF74
06648 
06649 /* File read error during image creation (MISHAP,HIGH, -141) */
06650 #define ISO_FILE_CANT_WRITE             0xE430FF73
06651 
06652 /* Can't convert filename to requested charset (WARNING,MEDIUM, -142) */
06653 #define ISO_FILENAME_WRONG_CHARSET      0xD020FF72
06654 /* This was once a HINT. Deprecated now. */
06655 #define ISO_FILENAME_WRONG_CHARSET_OLD  0xC020FF72
06656 
06657 /* File can't be added to the tree (SORRY,HIGH, -143) */
06658 #define ISO_FILE_CANT_ADD               0xE030FF71
06659 
06660 /**
06661  * File path break specification constraints and will be ignored
06662  * (WARNING,MEDIUM, -144)
06663  */
06664 #define ISO_FILE_IMGPATH_WRONG          0xD020FF70
06665 
06666 /**
06667  * Offset greater than file size (FAILURE,HIGH, -150)
06668  * @since 0.6.4
06669  */
06670 #define ISO_FILE_OFFSET_TOO_BIG         0xE830FF6A
06671 
06672 
06673 /** Charset conversion error (FAILURE,HIGH, -256) */
06674 #define ISO_CHARSET_CONV_ERROR          0xE830FF00
06675 
06676 /**
06677  * Too many files to mangle, i.e. we cannot guarantee unique file names
06678  * (FAILURE,HIGH, -257)
06679  */
06680 #define ISO_MANGLE_TOO_MUCH_FILES       0xE830FEFF
06681 
06682 /* image related errors */
06683 
06684 /**
06685  * Wrong or damaged Primary Volume Descriptor (FAILURE,HIGH, -320)
06686  * This could mean that the file is not a valid ISO image.
06687  */
06688 #define ISO_WRONG_PVD                   0xE830FEC0
06689 
06690 /** Wrong or damaged RR entry (SORRY,HIGH, -321) */
06691 #define ISO_WRONG_RR                    0xE030FEBF
06692 
06693 /** Unsupported RR feature (SORRY,HIGH, -322) */
06694 #define ISO_UNSUPPORTED_RR              0xE030FEBE
06695 
06696 /** Wrong or damaged ECMA-119 (FAILURE,HIGH, -323) */
06697 #define ISO_WRONG_ECMA119               0xE830FEBD
06698 
06699 /** Unsupported ECMA-119 feature (FAILURE,HIGH, -324) */
06700 #define ISO_UNSUPPORTED_ECMA119         0xE830FEBC
06701 
06702 /** Wrong or damaged El-Torito catalog (WARN,HIGH, -325) */
06703 #define ISO_WRONG_EL_TORITO             0xD030FEBB
06704 
06705 /** Unsupported El-Torito feature (WARN,HIGH, -326) */
06706 #define ISO_UNSUPPORTED_EL_TORITO       0xD030FEBA
06707 
06708 /** Can't patch an isolinux boot image (SORRY,HIGH, -327) */
06709 #define ISO_ISOLINUX_CANT_PATCH         0xE030FEB9
06710 
06711 /** Unsupported SUSP feature (SORRY,HIGH, -328) */
06712 #define ISO_UNSUPPORTED_SUSP            0xE030FEB8
06713 
06714 /** Error on a RR entry that can be ignored (WARNING,HIGH, -329) */
06715 #define ISO_WRONG_RR_WARN               0xD030FEB7
06716 
06717 /** Error on a RR entry that can be ignored (HINT,MEDIUM, -330) */
06718 #define ISO_SUSP_UNHANDLED              0xC020FEB6
06719 
06720 /** Multiple ER SUSP entries found (WARNING,HIGH, -331) */
06721 #define ISO_SUSP_MULTIPLE_ER            0xD030FEB5
06722 
06723 /** Unsupported volume descriptor found (HINT,MEDIUM, -332) */
06724 #define ISO_UNSUPPORTED_VD              0xC020FEB4
06725 
06726 /** El-Torito related warning (WARNING,HIGH, -333) */
06727 #define ISO_EL_TORITO_WARN              0xD030FEB3
06728 
06729 /** Image write cancelled (MISHAP,HIGH, -334) */
06730 #define ISO_IMAGE_WRITE_CANCELED        0xE430FEB2
06731 
06732 /** El-Torito image is hidden (WARNING,HIGH, -335) */
06733 #define ISO_EL_TORITO_HIDDEN            0xD030FEB1
06734 
06735 
06736 /** AAIP info with ACL or xattr in ISO image will be ignored
06737                                                           (NOTE, HIGH, -336) */
06738 #define ISO_AAIP_IGNORED          0xB030FEB0
06739 
06740 /** Error with decoding ACL from AAIP info (FAILURE, HIGH, -337) */
06741 #define ISO_AAIP_BAD_ACL          0xE830FEAF
06742 
06743 /** Error with encoding ACL for AAIP (FAILURE, HIGH, -338) */
06744 #define ISO_AAIP_BAD_ACL_TEXT     0xE830FEAE
06745 
06746 /** AAIP processing for ACL or xattr not enabled at compile time
06747                                                        (FAILURE, HIGH, -339) */
06748 #define ISO_AAIP_NOT_ENABLED      0xE830FEAD
06749 
06750 /** Error with decoding AAIP info for ACL or xattr (FAILURE, HIGH, -340) */
06751 #define ISO_AAIP_BAD_AASTRING     0xE830FEAC
06752 
06753 /** Error with reading ACL or xattr from local file (FAILURE, HIGH, -341) */
06754 #define ISO_AAIP_NO_GET_LOCAL     0xE830FEAB
06755 
06756 /** Error with attaching ACL or xattr to local file (FAILURE, HIGH, -342) */
06757 #define ISO_AAIP_NO_SET_LOCAL     0xE830FEAA
06758 
06759 /** Unallowed attempt to set an xattr with non-userspace name
06760                                                     (FAILURE, HIGH, -343) */
06761 #define ISO_AAIP_NON_USER_NAME    0xE830FEA9
06762 
06763 
06764 /** Too many references on a single IsoExternalFilterCommand
06765                                                     (FAILURE, HIGH, -344) */
06766 #define ISO_EXTF_TOO_OFTEN        0xE830FEA8
06767 
06768 /** Use of zlib was not enabled at compile time (FAILURE, HIGH, -345) */
06769 #define ISO_ZLIB_NOT_ENABLED      0xE830FEA7
06770 
06771 /** Cannot apply zisofs filter to file >= 4 GiB  (FAILURE, HIGH, -346) */
06772 #define ISO_ZISOFS_TOO_LARGE      0xE830FEA6
06773 
06774 /** Filter input differs from previous run  (FAILURE, HIGH, -347) */
06775 #define ISO_FILTER_WRONG_INPUT    0xE830FEA5
06776 
06777 /** zlib compression/decompression error  (FAILURE, HIGH, -348) */
06778 #define ISO_ZLIB_COMPR_ERR        0xE830FEA4
06779 
06780 /** Input stream is not in zisofs format  (FAILURE, HIGH, -349) */
06781 #define ISO_ZISOFS_WRONG_INPUT    0xE830FEA3
06782 
06783 /** Cannot set global zisofs parameters while filters exist
06784                                                        (FAILURE, HIGH, -350) */
06785 #define ISO_ZISOFS_PARAM_LOCK     0xE830FEA2
06786 
06787 /** Premature EOF of zlib input stream  (FAILURE, HIGH, -351) */
06788 #define ISO_ZLIB_EARLY_EOF        0xE830FEA1
06789 
06790 /**
06791  * Checksum area or checksum tag appear corrupted  (WARNING,HIGH, -352)
06792  * @since 0.6.22
06793 */
06794 #define ISO_MD5_AREA_CORRUPTED    0xD030FEA0
06795 
06796 /**
06797  * Checksum mismatch between checksum tag and data blocks
06798  * (FAILURE, HIGH, -353)
06799  * @since 0.6.22
06800 */
06801 #define ISO_MD5_TAG_MISMATCH      0xE830FE9F
06802 
06803 /**
06804  * Checksum mismatch in System Area, Volume Descriptors, or directory tree.
06805  * (FAILURE, HIGH, -354)
06806  * @since 0.6.22
06807 */
06808 #define ISO_SB_TREE_CORRUPTED     0xE830FE9E
06809 
06810 /**
06811  * Unexpected checksum tag type encountered.   (WARNING, HIGH, -355)
06812  * @since 0.6.22
06813 */
06814 #define ISO_MD5_TAG_UNEXPECTED    0xD030FE9D
06815 
06816 /**
06817  * Misplaced checksum tag encountered. (WARNING, HIGH, -356)
06818  * @since 0.6.22
06819 */
06820 #define ISO_MD5_TAG_MISPLACED     0xD030FE9C
06821 
06822 /**
06823  * Checksum tag with unexpected address range encountered.
06824  * (WARNING, HIGH, -357)
06825  * @since 0.6.22
06826 */
06827 #define ISO_MD5_TAG_OTHER_RANGE   0xD030FE9B
06828 
06829 /**
06830  * Detected file content changes while it was written into the image.
06831  * (MISHAP, HIGH, -358)
06832  * @since 0.6.22
06833 */
06834 #define ISO_MD5_STREAM_CHANGE     0xE430FE9A
06835 
06836 /**
06837  * Session does not start at LBA 0. scdbackup checksum tag not written.
06838  * (WARNING, HIGH, -359)
06839  * @since 0.6.24
06840 */
06841 #define ISO_SCDBACKUP_TAG_NOT_0   0xD030FE99
06842 
06843 /**
06844  * The setting of iso_write_opts_set_ms_block() leaves not enough room
06845  * for the prescibed size of iso_write_opts_set_overwrite_buf().
06846  * (FAILURE, HIGH, -360)
06847  * @since 0.6.36
06848  */
06849 #define ISO_OVWRT_MS_TOO_SMALL    0xE830FE98
06850 
06851 /**
06852  * The partition offset is not 0 and leaves not not enough room for
06853  * system area, volume descriptors, and checksum tags of the first tree.
06854  * (FAILURE, HIGH, -361)
06855  */
06856 #define ISO_PART_OFFST_TOO_SMALL   0xE830FE97
06857 
06858 /**
06859  * The ring buffer is smaller than 64 kB + partition offset.
06860  * (FAILURE, HIGH, -362)
06861  */
06862 #define ISO_OVWRT_FIFO_TOO_SMALL   0xE830FE96
06863 
06864 /** Use of libjte was not enabled at compile time (FAILURE, HIGH, -363) */
06865 #define ISO_LIBJTE_NOT_ENABLED     0xE830FE95
06866 
06867 /** Failed to start up Jigdo Template Extraction (FAILURE, HIGH, -364) */
06868 #define ISO_LIBJTE_START_FAILED    0xE830FE94
06869 
06870 /** Failed to finish Jigdo Template Extraction (FAILURE, HIGH, -365) */
06871 #define ISO_LIBJTE_END_FAILED      0xE830FE93
06872 
06873 /** Failed to process file for Jigdo Template Extraction
06874    (MISHAP, HIGH, -366) */
06875 #define ISO_LIBJTE_FILE_FAILED     0xE430FE92
06876 
06877 /** Too many MIPS Big Endian boot files given (max. 15) (FAILURE, HIGH, -367)*/
06878 #define ISO_BOOT_TOO_MANY_MIPS     0xE830FE91
06879 
06880 /** Boot file missing in image (MISHAP, HIGH, -368) */
06881 #define ISO_BOOT_FILE_MISSING      0xE430FE90
06882 
06883 /** Partition number out of range (FAILURE, HIGH, -369) */
06884 #define ISO_BAD_PARTITION_NO       0xE830FE8F
06885 
06886 /** Cannot open data file for appended partition (FAILURE, HIGH, -370) */
06887 #define ISO_BAD_PARTITION_FILE     0xE830FE8E
06888 
06889 /** May not combine appended partition with non-MBR system area
06890                                                        (FAILURE, HIGH, -371) */
06891 #define ISO_NON_MBR_SYS_AREA       0xE830FE8D
06892 
06893 /** Displacement offset leads outside 32 bit range (FAILURE, HIGH, -372) */
06894 #define ISO_DISPLACE_ROLLOVER      0xE830FE8C
06895 
06896 /** File name cannot be written into ECMA-119 untranslated
06897                                                        (FAILURE, HIGH, -373) */
06898 #define ISO_NAME_NEEDS_TRANSL      0xE830FE8B
06899 
06900 /** Data file input stream object offers no cloning method
06901                                                        (FAILURE, HIGH, -374) */
06902 #define ISO_STREAM_NO_CLONE        0xE830FE8A
06903 
06904 /** Extended information class offers no cloning method
06905                                                        (FAILURE, HIGH, -375) */
06906 #define ISO_XINFO_NO_CLONE         0xE830FE89
06907 
06908 /** Found copied superblock checksum tag  (WARNING, HIGH, -376) */
06909 #define ISO_MD5_TAG_COPIED         0xD030FE88
06910 
06911 /** Rock Ridge leaf name too long (FAILURE, HIGH, -377) */
06912 #define ISO_RR_NAME_TOO_LONG       0xE830FE87
06913 
06914 /** Reserved Rock Ridge leaf name  (FAILURE, HIGH, -378) */
06915 #define ISO_RR_NAME_RESERVED       0xE830FE86
06916 
06917 /** Rock Ridge path too long  (FAILURE, HIGH, -379) */
06918 #define ISO_RR_PATH_TOO_LONG       0xE830FE85
06919 
06920 /** Attribute name cannot be represented  (FAILURE, HIGH, -380) */
06921 #define ISO_AAIP_BAD_ATTR_NAME      0xE830FE84
06922 
06923 /** ACL text contains multiple entries of user::, group::, other::
06924                                                      (FAILURE, HIGH, -379)  */
06925 #define ISO_AAIP_ACL_MULT_OBJ       0xE830FE83
06926 
06927 
06928 
06929 /* Internal developer note: 
06930    Place new error codes directly above this comment. 
06931    Newly introduced errors must get a message entry in
06932    libisofs/message.c, function iso_error_to_msg()
06933 */
06934 
06935 /* ! PLACE NEW ERROR CODES ABOVE. NOT AFTER THIS LINE ! */
06936 
06937 
06938 /** Read error occured with IsoDataSource (SORRY,HIGH, -513) */
06939 #define ISO_DATA_SOURCE_SORRY     0xE030FCFF
06940 
06941 /** Read error occured with IsoDataSource (MISHAP,HIGH, -513) */
06942 #define ISO_DATA_SOURCE_MISHAP    0xE430FCFF
06943 
06944 /** Read error occured with IsoDataSource (FAILURE,HIGH, -513) */
06945 #define ISO_DATA_SOURCE_FAILURE   0xE830FCFF
06946 
06947 /** Read error occured with IsoDataSource (FATAL,HIGH, -513) */
06948 #define ISO_DATA_SOURCE_FATAL     0xF030FCFF
06949 
06950 
06951 /* ! PLACE NEW ERROR CODES SEVERAL LINES ABOVE. NOT HERE ! */
06952 
06953 
06954 /* ------------------------------------------------------------------------- */
06955 
06956 #ifdef LIBISOFS_WITHOUT_LIBBURN
06957 
06958 /**
06959     This is a copy from the API of libburn-0.6.0 (under GPL).
06960     It is supposed to be as stable as any overall include of libburn.h.
06961     I.e. if this definition is out of sync then you cannot rely on any
06962     contract that was made with libburn.h.
06963 
06964     Libisofs does not need to be linked with libburn at all. But if it is
06965     linked with libburn then it must be libburn-0.4.2 or later.
06966 
06967     An application that provides own struct burn_source objects and does not
06968     include libburn/libburn.h has to define LIBISOFS_WITHOUT_LIBBURN before
06969     including libisofs/libisofs.h in order to make this copy available.
06970 */ 
06971 
06972 
06973 /** Data source interface for tracks.
06974     This allows to use arbitrary program code as provider of track input data.
06975 
06976     Objects compliant to this interface are either provided by the application
06977     or by API calls of libburn: burn_fd_source_new() , burn_file_source_new(),
06978     and burn_fifo_source_new().
06979 
06980     The API calls allow to use any file object as data source. Consider to feed
06981     an eventual custom data stream asynchronously into a pipe(2) and to let
06982     libburn handle the rest. 
06983     In this case the following rule applies:
06984     Call burn_source_free() exactly once for every source obtained from
06985     libburn API. You MUST NOT otherwise use or manipulate its components.
06986 
06987     In general, burn_source objects can be freed as soon as they are attached
06988     to track objects. The track objects will keep them alive and dispose them
06989     when they are no longer needed. With a fifo burn_source it makes sense to
06990     keep the own reference for inquiring its state while burning is in
06991     progress.
06992 
06993     ---
06994 
06995     The following description of burn_source applies only to application
06996     implemented burn_source objects. You need not to know it for API provided
06997     ones.
06998 
06999     If you really implement an own passive data producer by this interface,
07000     then beware: it can do anything and it can spoil everything.
07001 
07002     In this case the functions (*read), (*get_size), (*set_size), (*free_data)
07003     MUST be implemented by the application and attached to the object at
07004     creation time.
07005     Function (*read_sub) is allowed to be NULL or it MUST be implemented and
07006     attached.
07007 
07008     burn_source.refcount MUST be handled properly: If not exactly as many
07009     references are freed as have been obtained, then either memory leaks or
07010     corrupted memory are the consequence.
07011     All objects which are referred to by *data must be kept existent until
07012     (*free_data) is called via burn_source_free() by the last referer.
07013 */
07014 struct burn_source {
07015 
07016     /** Reference count for the data source. MUST be 1 when a new source
07017             is created and thus the first reference is handed out. Increment
07018             it to take more references for yourself. Use burn_source_free()
07019             to destroy your references to it. */
07020     int refcount;
07021 
07022 
07023     /** Read data from the source. Semantics like with read(2), but MUST
07024         either deliver the full buffer as defined by size or MUST deliver
07025         EOF (return 0) or failure (return -1) at this call or at the
07026         next following call. I.e. the only incomplete buffer may be the
07027         last one from that source.
07028         libburn will read a single sector by each call to (*read).
07029         The size of a sector depends on BURN_MODE_*. The known range is
07030         2048 to 2352.
07031 
07032             If this call is reading from a pipe then it will learn
07033             about the end of data only when that pipe gets closed on the
07034             feeder side. So if the track size is not fixed or if the pipe
07035             delivers less than the predicted amount or if the size is not
07036             block aligned, then burning will halt until the input process
07037             closes the pipe.
07038 
07039         IMPORTANT:
07040         If this function pointer is NULL, then the struct burn_source is of
07041         version >= 1 and the job of .(*read)() is done by .(*read_xt)().
07042         See below, member .version.
07043     */
07044     int (*read)(struct burn_source *, unsigned char *buffer, int size);
07045 
07046 
07047     /** Read subchannel data from the source (NULL if lib generated) 
07048         WARNING: This is an obscure feature with CD raw write modes.
07049         Unless you checked the libburn code for correctness in that aspect
07050         you should not rely on raw writing with own subchannels.
07051         ADVICE: Set this pointer to NULL.
07052     */
07053     int (*read_sub)(struct burn_source *, unsigned char *buffer, int size);
07054 
07055 
07056     /** Get the size of the source's data. Return 0 means unpredictable
07057         size. If application provided (*get_size) allows return 0, then
07058         the application MUST provide a fully functional (*set_size).
07059     */
07060     off_t (*get_size)(struct burn_source *); 
07061 
07062 
07063         /* @since 0.3.2 */
07064     /** Program the reply of (*get_size) to a fixed value. It is advised
07065         to implement this by a attribute  off_t fixed_size;  in *data .
07066         The read() function does not have to take into respect this fake
07067         setting. It is rather a note of libburn to itself. Eventually
07068         necessary truncation or padding is done in libburn. Truncation
07069         is usually considered a misburn. Padding is considered ok.
07070 
07071         libburn is supposed to work even if (*get_size) ignores the
07072             setting by (*set_size). But your application will not be able to
07073         enforce fixed track sizes by  burn_track_set_size() and possibly
07074         even padding might be left out.
07075     */
07076     int (*set_size)(struct burn_source *source, off_t size);
07077 
07078 
07079     /** Clean up the source specific data. This function will be called
07080         once by burn_source_free() when the last referer disposes the
07081         source.
07082     */
07083     void (*free_data)(struct burn_source *);
07084 
07085 
07086     /** Next source, for when a source runs dry and padding is disabled
07087         WARNING: This is an obscure feature. Set to NULL at creation and
07088                  from then on leave untouched and uninterpreted.
07089     */
07090     struct burn_source *next;
07091 
07092 
07093     /** Source specific data. Here the various source classes express their
07094         specific properties and the instance objects store their individual
07095         management data.
07096             E.g. data could point to a struct like this:
07097         struct app_burn_source
07098         {
07099             struct my_app *app_handle;
07100             ... other individual source parameters ...
07101             off_t fixed_size;
07102         };
07103 
07104         Function (*free_data) has to be prepared to clean up and free
07105         the struct.
07106     */
07107     void *data;
07108 
07109 
07110         /* @since 0.4.2 */
07111     /** Valid only if above member .(*read)() is NULL. This indicates a
07112         version of struct burn_source younger than 0.
07113         From then on, member .version tells which further members exist
07114         in the memory layout of struct burn_source. libburn will only touch
07115         those announced extensions.
07116 
07117         Versions:
07118          0  has .(*read)() != NULL, not even .version is present.
07119              1  has .version, .(*read_xt)(), .(*cancel)()
07120     */
07121     int version;
07122 
07123     /** This substitutes for (*read)() in versions above 0. */
07124     int (*read_xt)(struct burn_source *, unsigned char *buffer, int size);
07125 
07126     /** Informs the burn_source that the consumer of data prematurely
07127         ended reading. This call may or may not be issued by libburn
07128         before (*free_data)() is called.
07129     */
07130     int (*cancel)(struct burn_source *source);
07131 };
07132 
07133 #endif /* LIBISOFS_WITHOUT_LIBBURN */
07134 
07135 /* ----------------------------- Bug Fixes ----------------------------- */
07136 
07137 /* currently none being tested */
07138 
07139 
07140 /* ---------------------------- Improvements --------------------------- */
07141 
07142 /* currently none being tested */
07143 
07144 
07145 /* ---------------------------- Experiments ---------------------------- */
07146 
07147 
07148 /* Experiment: Write obsolete RR entries with Rock Ridge.
07149                I suspect Solaris wants to see them.
07150                DID NOT HELP: Solaris knows only RRIP_1991A.
07151 
07152  #define Libisofs_with_rrip_rR yes
07153 */
07154 
07155 
07156 #endif /*LIBISO_LIBISOFS_H_*/

Generated for libisofs by  doxygen 1.7.4