Moved storage location of suffix from xorriso into IsoExternalFilterCommand
This commit is contained in:
parent
0a265d9d4f
commit
437713cd8e
@ -46,11 +46,6 @@ typedef struct
|
||||
int out_eof;
|
||||
uint8_t pipebuf[2048]; /* buffers in case of EAGAIN on write() */
|
||||
int pipebuf_fill;
|
||||
|
||||
#ifdef Libisofs_extf_old_behavior_bit_0
|
||||
int is_0_run;
|
||||
#endif
|
||||
|
||||
} ExternalFilterRuntime;
|
||||
|
||||
|
||||
@ -72,11 +67,6 @@ int extf_running_new(ExternalFilterRuntime **running, int send_fd, int recv_fd,
|
||||
o->out_eof = 0;
|
||||
memset(o->pipebuf, 0, sizeof(o->pipebuf));
|
||||
o->pipebuf_fill = 0;
|
||||
|
||||
#ifdef Libisofs_extf_old_behavior_bit_0
|
||||
o->is_0_run = 0;
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -128,26 +118,10 @@ int extf_stream_open_flag(IsoStream *stream, int flag)
|
||||
return ISO_NULL_POINTER;
|
||||
}
|
||||
data = (ExternalFilterStreamData*)stream->data;
|
||||
|
||||
if (data->running != NULL) {
|
||||
return ISO_FILE_ALREADY_OPENED;
|
||||
}
|
||||
|
||||
#ifdef Libisofs_extf_old_behavior_bit_0
|
||||
if (data->cmd->behavior & 1) {
|
||||
if (iso_stream_get_size(data->orig) == 0) {
|
||||
/* Do not fork. Place message for .read and .close */;
|
||||
ret = extf_running_new(&running, -1, -1, 0, 0);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
running->is_0_run = 1;
|
||||
data->running = running;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
#endif /* Libisofs_extf_old_behavior_bit_0 */
|
||||
|
||||
if (data->size < 0 && !(flag & 1)) {
|
||||
/* Do the size determination run now, so that the size gets cached
|
||||
and .get_size() will not fail on an opened stream.
|
||||
@ -260,11 +234,6 @@ static
|
||||
int extf_stream_close(IsoStream *stream)
|
||||
{
|
||||
int ret, status;
|
||||
|
||||
#ifdef Libisofs_extf_old_behavior_bit_0
|
||||
int is_0_run;
|
||||
#endif
|
||||
|
||||
ExternalFilterStreamData *data;
|
||||
|
||||
if (stream == NULL) {
|
||||
@ -276,34 +245,18 @@ int extf_stream_close(IsoStream *stream)
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef Libisofs_extf_old_behavior_bit_0
|
||||
is_0_run = data->running->is_0_run;
|
||||
if (!is_0_run) {
|
||||
#endif
|
||||
if(data->running->recv_fd != -1)
|
||||
close(data->running->recv_fd);
|
||||
if(data->running->send_fd != -1)
|
||||
close(data->running->send_fd);
|
||||
|
||||
if(data->running->recv_fd != -1)
|
||||
close(data->running->recv_fd);
|
||||
if(data->running->send_fd != -1)
|
||||
close(data->running->send_fd);
|
||||
|
||||
ret = waitpid(data->running->pid, &status, WNOHANG);
|
||||
if (ret == 0 && data->running->pid != 0) {
|
||||
kill(data->running->pid, SIGKILL);
|
||||
waitpid(data->running->pid, &status, 0);
|
||||
}
|
||||
|
||||
#ifdef Libisofs_extf_old_behavior_bit_0
|
||||
ret = waitpid(data->running->pid, &status, WNOHANG);
|
||||
if (ret == 0 && data->running->pid != 0) {
|
||||
kill(data->running->pid, SIGKILL);
|
||||
waitpid(data->running->pid, &status, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
free(data->running);
|
||||
data->running = NULL;
|
||||
|
||||
#ifdef Libisofs_extf_old_behavior_bit_0
|
||||
if (is_0_run)
|
||||
return 1;
|
||||
#endif
|
||||
|
||||
return iso_stream_close(data->orig);
|
||||
}
|
||||
|
||||
@ -324,13 +277,7 @@ int extf_stream_read(IsoStream *stream, void *buf, size_t desired)
|
||||
if (running == NULL) {
|
||||
return ISO_FILE_NOT_OPENED;
|
||||
}
|
||||
|
||||
#ifdef Libisofs_extf_old_behavior_bit_0
|
||||
if (running->out_eof || running->is_0_run) {
|
||||
#else
|
||||
if (running->out_eof) {
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -506,6 +453,7 @@ int extf_update_size(IsoStream *stream)
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
IsoStream *extf_get_input_stream(IsoStream *stream, int flag)
|
||||
{
|
||||
ExternalFilterStreamData *data;
|
||||
@ -632,11 +580,7 @@ int iso_file_add_external_filter(IsoFile *file, IsoExternalFilterCommand *cmd,
|
||||
IsoStream *stream;
|
||||
off_t original_size = 0, filtered_size = 0;
|
||||
|
||||
#ifdef Libisofs_extf_old_behavior_bit_0
|
||||
if (cmd->behavior & (2 | 4)) {
|
||||
#else
|
||||
if (cmd->behavior & (1 | 2 | 4)) {
|
||||
#endif
|
||||
original_size = iso_file_get_size(file);
|
||||
if (original_size <= 0 ||
|
||||
((cmd->behavior & 4) && original_size <= 2048)) {
|
||||
@ -669,3 +613,18 @@ int iso_file_add_external_filter(IsoFile *file, IsoExternalFilterCommand *cmd,
|
||||
return ISO_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
int iso_file_get_external_filter(IsoFile *file, IsoExternalFilterCommand **cmd,
|
||||
int flag)
|
||||
{
|
||||
IsoStream *stream;
|
||||
ExternalFilterStreamData *data;
|
||||
|
||||
stream = iso_file_get_stream(file);
|
||||
if (stream->class != &extf_stream_class)
|
||||
return 0;
|
||||
data = stream->data;
|
||||
*cmd = data->cmd;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -4695,6 +4695,11 @@ struct iso_external_filter_command
|
||||
*/
|
||||
int refcount;
|
||||
|
||||
/* An optional instance id.
|
||||
* Set to empty text if no individual name for this object is intended.
|
||||
*/
|
||||
char *name;
|
||||
|
||||
/* Absolute local filesystem path to the executable program. */
|
||||
char *path;
|
||||
|
||||
@ -4709,25 +4714,25 @@ struct iso_external_filter_command
|
||||
char **argv;
|
||||
|
||||
/* A bit field which controls behavior variations:
|
||||
|
||||
#ifdef Libisofs_extf_old_behavior_bit_0
|
||||
* bit0= Shortcut: 0 sized input will surely yield 0 sized output
|
||||
#else
|
||||
* bit0= Do not install filter if the input has size 0.
|
||||
#endif
|
||||
|
||||
* bit1= Do not install filter if the output is not smaller than the input.
|
||||
* bit2= Do not install filter if the number of output blocks is
|
||||
* not smaller than the number of input blocks. Block size is 2048.
|
||||
* Assume that non-empty input yields non-empty output and thus do
|
||||
* not attempt to attach a filter to files smaller than 2049 bytes.
|
||||
* bit3= suffix was removed rather than to be added.
|
||||
* (Removal and adding suffixes is the task of the application.
|
||||
* This behavior bit serves only as reminder for the application.)
|
||||
*/
|
||||
int behavior;
|
||||
|
||||
/* An optional instance id.
|
||||
* Set to NULL if no individual name for this object is intended.
|
||||
/* The eventual suffix which is supposed to be added to the IsoFile name
|
||||
* resp. to be removed from the name.
|
||||
* (This is to be done by the application, not by calls
|
||||
* iso_file_add_external_filter() or iso_file_remove_filter().
|
||||
* The value recorded here serves only as reminder for the application.)
|
||||
*/
|
||||
char *name;
|
||||
char *suffix;
|
||||
};
|
||||
|
||||
typedef struct iso_external_filter_command IsoExternalFilterCommand;
|
||||
@ -4781,6 +4786,27 @@ int iso_file_add_external_filter(IsoFile *file, IsoExternalFilterCommand *cmd,
|
||||
int iso_file_remove_filter(IsoFile *file, int flag);
|
||||
|
||||
|
||||
/* ts A90402 */
|
||||
/**
|
||||
* Obtain the IsoExternalFilterCommand which is associated with the top filter
|
||||
* stream from a data file.
|
||||
* @param file
|
||||
* The data file node which shall show filtered content.
|
||||
* @param cmd
|
||||
* Will return the external IsoExternalFilterCommand. This does not
|
||||
* increment .refcount.
|
||||
* @param flag
|
||||
* Bitfield for control purposes, unused yet, submit 0.
|
||||
* @return
|
||||
* 1 on success, 0 if the top stream of the file is not an external filter
|
||||
* <0 on error
|
||||
*
|
||||
* @since 0.6.18
|
||||
*/
|
||||
int iso_file_get_external_filter(IsoFile *file, IsoExternalFilterCommand **cmd,
|
||||
int flag);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
#ifdef LIBISOFS_WITHOUT_LIBBURN
|
||||
|
Loading…
Reference in New Issue
Block a user