Switch to Vreixo development branch 362
This commit is contained in:
parent
4cd4dd3040
commit
9f6b7e4e3f
@ -641,6 +641,119 @@ struct iso_file_source
|
||||
void *data;
|
||||
};
|
||||
|
||||
/**
|
||||
* Representation of file contents. It is an stream of bytes, functionally
|
||||
* like a pipe.
|
||||
*
|
||||
* @since 0.6.4
|
||||
*/
|
||||
typedef struct iso_stream IsoStream;
|
||||
|
||||
/**
|
||||
* Interface that defines the operations (methods) available for an
|
||||
* IsoStream.
|
||||
*
|
||||
* @see struct IsoStream_Iface
|
||||
* @since 0.6.4
|
||||
*/
|
||||
typedef struct IsoStream_Iface IsoStreamIface;
|
||||
|
||||
/**
|
||||
* Serial number to be used when you can't get a valid id for a Stream by other
|
||||
* means. If you use this, both fs_id and dev_id should be set to 0.
|
||||
* This must be incremented each time you get a reference to it.
|
||||
*
|
||||
* @see IsoStreamIface->get_id()
|
||||
* @since 0.6.4
|
||||
*/
|
||||
extern ino_t serial_id;
|
||||
|
||||
/**
|
||||
* Interface definition for IsoStream methods.
|
||||
*
|
||||
* @since 0.6.4
|
||||
*/
|
||||
struct IsoStream_Iface
|
||||
{
|
||||
/**
|
||||
* Opens the stream.
|
||||
*
|
||||
* @return
|
||||
* 1 on success, 2 file greater than expected, 3 file smaller than
|
||||
* expected, < 0 on error
|
||||
*/
|
||||
int (*open)(IsoStream *stream);
|
||||
|
||||
/**
|
||||
* Close the Stream.
|
||||
* @return 1 on success, < 0 on error
|
||||
*/
|
||||
int (*close)(IsoStream *stream);
|
||||
|
||||
/**
|
||||
* Get the size (in bytes) of the stream. This function should always
|
||||
* return the same size, even if the underlying source size changes.
|
||||
*/
|
||||
off_t (*get_size)(IsoStream *stream);
|
||||
|
||||
/**
|
||||
* Attempts to read up to count bytes from the given stream into
|
||||
* the buffer starting at buf.
|
||||
*
|
||||
* The stream must be open() before calling this, and close() when no
|
||||
* more needed.
|
||||
*
|
||||
* @return
|
||||
* number of bytes read, 0 if EOF, < 0 on error
|
||||
*/
|
||||
int (*read)(IsoStream *stream, void *buf, size_t count);
|
||||
|
||||
/**
|
||||
* Whether this IsoStream can be read several times, with the same results.
|
||||
* For example, a regular file is repeatable, you can read it as many
|
||||
* times as you want. However, a pipe isn't.
|
||||
*
|
||||
* This function doesn't take into account if the file has been modified
|
||||
* between the two reads.
|
||||
*
|
||||
* @return
|
||||
* 1 if stream is repeatable, 0 if not, < 0 on error
|
||||
*/
|
||||
int (*is_repeatable)(IsoStream *stream);
|
||||
|
||||
/**
|
||||
* Get an unique identifier for the IsoStream.
|
||||
*/
|
||||
void (*get_id)(IsoStream *stream, unsigned int *fs_id, dev_t *dev_id,
|
||||
ino_t *ino_id);
|
||||
|
||||
/**
|
||||
* Get a name that identifies the Stream contents. It is used only for
|
||||
* informational or debug purposes, so you can return anything you
|
||||
* consider suitable for identification of the source, such as the path
|
||||
* of the file on disc.
|
||||
*/
|
||||
char *(*get_name)(IsoStream *stream);
|
||||
|
||||
/**
|
||||
* Free implementation specific data. Should never be called by user.
|
||||
* Use iso_stream_unref() instead.
|
||||
*/
|
||||
void (*free)(IsoStream *stream);
|
||||
};
|
||||
|
||||
/**
|
||||
* Representation of file contents as a stream of bytes.
|
||||
*
|
||||
* @since 0.6.4
|
||||
*/
|
||||
struct iso_stream
|
||||
{
|
||||
IsoStreamIface *class;
|
||||
int refcount;
|
||||
void *data;
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize libisofs. You must call this before any usage of the library.
|
||||
* @return 1 on success, < 0 on error
|
||||
@ -2099,6 +2212,20 @@ int iso_file_get_sort_weight(IsoFile *file);
|
||||
*/
|
||||
off_t iso_file_get_size(IsoFile *file);
|
||||
|
||||
/**
|
||||
* Get the IsoStream that represents the contents of the given IsoFile.
|
||||
*
|
||||
* If you open() the stream, it should be close() before image generation.
|
||||
*
|
||||
* @return
|
||||
* The IsoStream. No extra ref is added, so the IsoStream belong to the
|
||||
* IsoFile, and it may be freed together with it. Add your own ref with
|
||||
* iso_stream_ref() if you need it.
|
||||
*
|
||||
* @since 0.6.4
|
||||
*/
|
||||
IsoStream *iso_file_get_stream(IsoFile *file);
|
||||
|
||||
/**
|
||||
* Add a new directory to the iso tree. Permissions, owner and hidden atts
|
||||
* are taken from parent, you can modify them later.
|
||||
@ -2527,47 +2654,60 @@ int iso_obtain_msgs(char *minimum_severity, int *error_code, int *imgid,
|
||||
char msg_text[], char severity[]);
|
||||
|
||||
|
||||
/** Submit a message to the libisofs queueing system. It will be queued or
|
||||
printed as if it was generated by libburn itself.
|
||||
@param error_code The unique error code of your message.
|
||||
Submit 0 if you do not have reserved error codes within
|
||||
the libburnia project.
|
||||
@param msg_text Not more than ISO_MSGS_MESSAGE_LEN characters of
|
||||
message text.
|
||||
@param os_errno Eventual errno related to the message. Submit 0 if
|
||||
the message is not related to a operating system error.
|
||||
@param severity One of "ABORT", "FATAL", "FAILURE", "SORRY", "WARNING",
|
||||
"HINT", "NOTE", "UPDATE", "DEBUG". Defaults to "ALL".
|
||||
@param origin Submit 0 for now.
|
||||
@return 1 if message was delivered, <=0 if failure
|
||||
|
||||
@since 0.6.4
|
||||
*/
|
||||
/**
|
||||
* Submit a message to the libisofs queueing system. It will be queued or
|
||||
* printed as if it was generated by libisofs itself.
|
||||
*
|
||||
* @param error_code
|
||||
* The unique error code of your message.
|
||||
* Submit 0 if you do not have reserved error codes within the libburnia
|
||||
* project.
|
||||
* @param msg_text
|
||||
* Not more than ISO_MSGS_MESSAGE_LEN characters of message text.
|
||||
* @param os_errno
|
||||
* Eventual errno related to the message. Submit 0 if the message is not
|
||||
* related to a operating system error.
|
||||
* @param severity
|
||||
* One of "ABORT", "FATAL", "FAILURE", "SORRY", "WARNING", "HINT", "NOTE",
|
||||
* "UPDATE", "DEBUG". Defaults to "FATAL".
|
||||
* @param origin
|
||||
* Submit 0 for now.
|
||||
* @return
|
||||
* 1 if message was delivered, <=0 if failure
|
||||
*
|
||||
* @since 0.6.4
|
||||
*/
|
||||
int iso_msgs_submit(int error_code, char msg_text[], int os_errno,
|
||||
char severity[], int origin);
|
||||
|
||||
|
||||
/** Convert a severity name into a severity number, which gives the severity
|
||||
rank of the name.
|
||||
@since 0.6.4
|
||||
@param severity_name A name as with iso_msgs_submit(), e.g. "SORRY".
|
||||
@param severity_number The rank number: the higher, the more severe.
|
||||
@param flag Bitfield for control purposes (unused yet, submit 0)
|
||||
@return >0 success, <=0 failure
|
||||
|
||||
@since 0.6.4
|
||||
*/
|
||||
int iso_text_to_sev(char *severity_name, int *severity_number, int flag);
|
||||
/**
|
||||
* Convert a severity name into a severity number, which gives the severity
|
||||
* rank of the name.
|
||||
*
|
||||
* @param severity_name
|
||||
* A name as with iso_msgs_submit(), e.g. "SORRY".
|
||||
* @param severity_number
|
||||
* The rank number: the higher, the more severe.
|
||||
* @return
|
||||
* >0 success, <=0 failure
|
||||
*
|
||||
* @since 0.6.4
|
||||
*/
|
||||
int iso_text_to_sev(char *severity_name, int *severity_number);
|
||||
|
||||
|
||||
/** Convert a severity number into a severity name
|
||||
@param severity_number The rank number: the higher, the more severe.
|
||||
@param severity_name A name as with iso_msgs_submit(), e.g. "SORRY".
|
||||
@param flag Bitfield for control purposes (unused yet, submit 0)
|
||||
|
||||
@since 0.6.4
|
||||
*/
|
||||
int iso_sev_to_text(int severity_number, char **severity_name, int flag);
|
||||
/**
|
||||
* Convert a severity number into a severity name
|
||||
*
|
||||
* @param severity_number
|
||||
* The rank number: the higher, the more severe.
|
||||
* @param severity_name
|
||||
* A name as with iso_msgs_submit(), e.g. "SORRY".
|
||||
*
|
||||
* @since 0.6.4
|
||||
*/
|
||||
int iso_sev_to_text(int severity_number, char **severity_name);
|
||||
|
||||
|
||||
/**
|
||||
@ -2977,6 +3117,103 @@ const char *iso_image_fs_get_abstract_file_id(IsoImageFilesystem *fs);
|
||||
*/
|
||||
const char *iso_image_fs_get_biblio_file_id(IsoImageFilesystem *fs);
|
||||
|
||||
/**
|
||||
* Increment reference count of an IsoStream.
|
||||
*
|
||||
* @since 0.6.4
|
||||
*/
|
||||
void iso_stream_ref(IsoStream *stream);
|
||||
|
||||
/**
|
||||
* Decrement reference count of an IsoStream, and eventually free it if
|
||||
* refcount reach 0.
|
||||
*
|
||||
* @since 0.6.4
|
||||
*/
|
||||
void iso_stream_unref(IsoStream *stream);
|
||||
|
||||
/**
|
||||
* Opens the given stream. Remember to close the Stream before writing the
|
||||
* image.
|
||||
*
|
||||
* @return
|
||||
* 1 on success, 2 file greater than expected, 3 file smaller than
|
||||
* expected, < 0 on error
|
||||
*
|
||||
* @since 0.6.4
|
||||
*/
|
||||
int iso_stream_open(IsoStream *stream);
|
||||
|
||||
/**
|
||||
* Close a previously openned IsoStream.
|
||||
*
|
||||
* @return
|
||||
* 1 on success, < 0 on error
|
||||
*
|
||||
* @since 0.6.4
|
||||
*/
|
||||
int iso_stream_close(IsoStream *stream);
|
||||
|
||||
/**
|
||||
* Get the size of a given stream. This function should always return the same
|
||||
* size, even if the underlying source size changes.
|
||||
*
|
||||
* @return
|
||||
* IsoStream size in bytes
|
||||
*
|
||||
* @since 0.6.4
|
||||
*/
|
||||
off_t iso_stream_get_size(IsoStream *stream);
|
||||
|
||||
/**
|
||||
* Attempts to read up to count bytes from the given stream into
|
||||
* the buffer starting at buf.
|
||||
*
|
||||
* The stream must be open() before calling this, and close() when no
|
||||
* more needed.
|
||||
*
|
||||
* @return
|
||||
* number of bytes read, 0 if EOF, < 0 on error
|
||||
*
|
||||
* @since 0.6.4
|
||||
*/
|
||||
int iso_stream_read(IsoStream *stream, void *buf, size_t count);
|
||||
|
||||
/**
|
||||
* Whether the given IsoStream can be read several times, with the same
|
||||
* results.
|
||||
* For example, a regular file is repeatable, you can read it as many
|
||||
* times as you want. However, a pipe isn't.
|
||||
*
|
||||
* This function doesn't take into account if the file has been modified
|
||||
* between the two reads.
|
||||
*
|
||||
* @return
|
||||
* 1 if stream is repeatable, 0 if not, < 0 on error
|
||||
*
|
||||
* @since 0.6.4
|
||||
*/
|
||||
int iso_stream_is_repeatable(IsoStream *stream);
|
||||
|
||||
/**
|
||||
* Get an unique identifier for a given IsoStream.
|
||||
*
|
||||
* @since 0.6.4
|
||||
*/
|
||||
void iso_stream_get_id(IsoStream *stream, unsigned int *fs_id, dev_t *dev_id,
|
||||
ino_t *ino_id);
|
||||
|
||||
/**
|
||||
* Get a name that identifies the Stream contents. It is used only for
|
||||
* informational or debug purposes, so you can return anything you
|
||||
* consider suitable for identification of the source, such as the path
|
||||
* of the file on disc.
|
||||
* Returned string should be freed when no more needed.
|
||||
*
|
||||
* @since 0.6.4
|
||||
*/
|
||||
char *iso_stream_get_name(IsoStream *stream);
|
||||
|
||||
/************ Error codes and return values for libisofs ********************/
|
||||
|
||||
/** successfully execution */
|
||||
|
@ -367,7 +367,7 @@ int iso_msgs_submit(int error_code, char msg_text[], int os_errno,
|
||||
|
||||
/* ts A80222 : derived from libburn/init.c:burn_text_to_sev()
|
||||
*/
|
||||
int iso_text_to_sev(char *severity_name, int *sevno, int flag)
|
||||
int iso_text_to_sev(char *severity_name, int *sevno)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@ -380,7 +380,7 @@ int iso_text_to_sev(char *severity_name, int *sevno, int flag)
|
||||
|
||||
/* ts A80222 : derived from libburn/init.c:burn_sev_to_text()
|
||||
*/
|
||||
int iso_sev_to_text(int severity_number, char **severity_name, int flag)
|
||||
int iso_sev_to_text(int severity_number, char **severity_name)
|
||||
{
|
||||
int ret;
|
||||
|
||||
|
@ -601,6 +601,23 @@ off_t iso_file_get_size(IsoFile *file)
|
||||
return iso_stream_get_size(file->stream);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the IsoStream that represents the contents of the given IsoFile.
|
||||
*
|
||||
* If you open() the stream, it should be close() before image generation.
|
||||
*
|
||||
* @return
|
||||
* The IsoStream. No extra ref is added, so the IsoStream belong to the
|
||||
* IsoFile, and it may be freed together with it. Add your own ref with
|
||||
* iso_stream_ref() if you need it.
|
||||
*
|
||||
* @since 0.6.4
|
||||
*/
|
||||
IsoStream *iso_file_get_stream(IsoFile *file)
|
||||
{
|
||||
return file->stream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a given name is valid for an iso node.
|
||||
*
|
||||
|
@ -13,113 +13,13 @@
|
||||
*/
|
||||
#include "fsource.h"
|
||||
|
||||
/**
|
||||
* serial number to be used when you can't get a valid id for a Stream by other
|
||||
* means. If you use this, both fs_id and dev_id should be set to 0.
|
||||
* This must be incremented each time you get a reference to it.
|
||||
*/
|
||||
extern ino_t serial_id;
|
||||
/* TODO consider removing this header */
|
||||
|
||||
/*
|
||||
* Some functions here will be moved to libisofs.h when we expose
|
||||
* Streams.
|
||||
*/
|
||||
|
||||
typedef struct Iso_Stream IsoStream;
|
||||
|
||||
typedef struct IsoStream_Iface
|
||||
{
|
||||
/**
|
||||
* Opens the stream.
|
||||
*
|
||||
* @return
|
||||
* 1 on success, 2 file greater than expected, 3 file smaller than
|
||||
* expected, < 0 on error
|
||||
*/
|
||||
int (*open)(IsoStream *stream);
|
||||
|
||||
/**
|
||||
* Close the Stream.
|
||||
* @return 1 on success, < 0 on error
|
||||
*/
|
||||
int (*close)(IsoStream *stream);
|
||||
|
||||
/**
|
||||
* Get the size (in bytes) of the stream. This function should always
|
||||
* return the same size, even if the underlying source size changes.
|
||||
*/
|
||||
off_t (*get_size)(IsoStream *stream);
|
||||
|
||||
/**
|
||||
* Attempts to read up to count bytes from the given stream into
|
||||
* the buffer starting at buf.
|
||||
*
|
||||
* The stream must be open() before calling this, and close() when no
|
||||
* more needed.
|
||||
*
|
||||
* @return
|
||||
* number of bytes read, 0 if EOF, < 0 on error
|
||||
*/
|
||||
int (*read)(IsoStream *stream, void *buf, size_t count);
|
||||
|
||||
/**
|
||||
* Whether this Stram can be read several times, with the same results.
|
||||
* For example, a regular file is repeatable, you can read it as many
|
||||
* times as you want. However, a pipe isn't.
|
||||
*
|
||||
* This function doesn't take into account if the file has been modified
|
||||
* between the two reads.
|
||||
*
|
||||
* @return
|
||||
* 1 if stream is repeatable, 0 if not, < 0 on error
|
||||
*/
|
||||
int (*is_repeatable)(IsoStream *stream);
|
||||
|
||||
/**
|
||||
* Get an unique identifier for the IsoStream.
|
||||
*/
|
||||
void (*get_id)(IsoStream *stream, unsigned int *fs_id, dev_t *dev_id,
|
||||
ino_t *ino_id);
|
||||
|
||||
/**
|
||||
* Get a name that identifies the Stream contents. It is used only for
|
||||
* informational or debug purposes, so you can return anything you
|
||||
* consider suitable for identification of the source, such as the path.
|
||||
*/
|
||||
char *(*get_name)(IsoStream *stream);
|
||||
|
||||
/**
|
||||
* Free implementation specific data. Should never be called by user.
|
||||
* Use iso_stream_unref() instead.
|
||||
*/
|
||||
void (*free)(IsoStream *stream);
|
||||
} IsoStreamIface;
|
||||
|
||||
struct Iso_Stream
|
||||
{
|
||||
IsoStreamIface *class;
|
||||
int refcount;
|
||||
void *data;
|
||||
};
|
||||
|
||||
void iso_stream_ref(IsoStream *stream);
|
||||
void iso_stream_unref(IsoStream *stream);
|
||||
|
||||
int iso_stream_open(IsoStream *stream);
|
||||
|
||||
int iso_stream_close(IsoStream *stream);
|
||||
|
||||
off_t iso_stream_get_size(IsoStream *stream);
|
||||
|
||||
int iso_stream_read(IsoStream *stream, void *buf, size_t count);
|
||||
|
||||
int iso_stream_is_repeatable(IsoStream *stream);
|
||||
|
||||
void iso_stream_get_id(IsoStream *stream, unsigned int *fs_id, dev_t *dev_id,
|
||||
ino_t *ino_id);
|
||||
|
||||
char *iso_stream_get_name(IsoStream *stream);
|
||||
|
||||
/**
|
||||
* Create a stream to read from a IsoFileSource.
|
||||
* The stream will take the ref. to the IsoFileSource, so after a successfully
|
||||
|
Loading…
Reference in New Issue
Block a user