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

Generated for libisofs by  doxygen 1.7.4