Define code style formatter for eclipse and apply it to source.
This commit is contained in:
parent
1ecb735e7c
commit
4c9d83f051
@ -313,6 +313,7 @@
|
|||||||
</profile>
|
</profile>
|
||||||
</scannerConfigBuildInfo>
|
</scannerConfigBuildInfo>
|
||||||
</storageModule>
|
</storageModule>
|
||||||
|
<storageModule moduleId="org.eclipse.cdt.core.language.mapping"/>
|
||||||
</cconfiguration>
|
</cconfiguration>
|
||||||
<cconfiguration id="converted.config.2029700129.1058518760.974771800">
|
<cconfiguration id="converted.config.2029700129.1058518760.974771800">
|
||||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="converted.config.2029700129.1058518760.974771800" moduleId="org.eclipse.cdt.core.settings" name="test">
|
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="converted.config.2029700129.1058518760.974771800" moduleId="org.eclipse.cdt.core.settings" name="test">
|
||||||
@ -624,6 +625,7 @@
|
|||||||
</profile>
|
</profile>
|
||||||
</scannerConfigBuildInfo>
|
</scannerConfigBuildInfo>
|
||||||
</storageModule>
|
</storageModule>
|
||||||
|
<storageModule moduleId="org.eclipse.cdt.core.language.mapping"/>
|
||||||
</cconfiguration>
|
</cconfiguration>
|
||||||
</storageModule>
|
</storageModule>
|
||||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#Fri Dec 28 17:36:33 CET 2007
|
#Fri Dec 28 21:07:56 CET 2007
|
||||||
eclipse.preferences.version=1
|
eclipse.preferences.version=1
|
||||||
indexer/filesToParseUpFront=
|
indexer/filesToParseUpFront=
|
||||||
indexer/indexAllFiles=true
|
indexer/indexAllFiles=true
|
||||||
|
@ -22,7 +22,8 @@
|
|||||||
* the libisofs ring buffer as intermediate memory
|
* the libisofs ring buffer as intermediate memory
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct th_data {
|
struct th_data
|
||||||
|
{
|
||||||
IsoRingBuffer *rbuf;
|
IsoRingBuffer *rbuf;
|
||||||
char *path;
|
char *path;
|
||||||
};
|
};
|
||||||
@ -46,19 +47,19 @@ void *write_function(void *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
res = 1;
|
res = 1;
|
||||||
while ( (bytes = read(fd, tmp, WRITE_CHUNK)) > 0 ) {
|
while ( (bytes = read(fd, tmp, WRITE_CHUNK)) > 0) {
|
||||||
res = iso_ring_buffer_write(data->rbuf, tmp, bytes);
|
res = iso_ring_buffer_write(data->rbuf, tmp, bytes);
|
||||||
if (res <= 0) {
|
if (res <= 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* To test premature reader exit >>>>>>>>>>>
|
/* To test premature reader exit >>>>>>>>>>>
|
||||||
iso_ring_buffer_writer_close(data->rbuf);
|
iso_ring_buffer_writer_close(data->rbuf);
|
||||||
pthread_exit(NULL);
|
pthread_exit(NULL);
|
||||||
<<<<<<<<<<<<<<<<<<<<<<<<< */
|
<<<<<<<<<<<<<<<<<<<<<<<<< */
|
||||||
// if (rand() > 2000000000) {
|
// if (rand() > 2000000000) {
|
||||||
// fprintf(stderr, "Writer sleeping\n");
|
// fprintf(stderr, "Writer sleeping\n");
|
||||||
// sleep(1);
|
// sleep(1);
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
fprintf(stderr, "Writer finish: %d\n", res);
|
fprintf(stderr, "Writer finish: %d\n", res);
|
||||||
|
|
||||||
@ -74,16 +75,16 @@ void *read_function(void *arg)
|
|||||||
int res = 1;
|
int res = 1;
|
||||||
struct th_data *data = (struct th_data *) arg;
|
struct th_data *data = (struct th_data *) arg;
|
||||||
|
|
||||||
while ( (res = iso_ring_buffer_read(data->rbuf, tmp, READ_CHUNK)) > 0 ) {
|
while ( (res = iso_ring_buffer_read(data->rbuf, tmp, READ_CHUNK)) > 0) {
|
||||||
write(1, tmp, READ_CHUNK);
|
write(1, tmp, READ_CHUNK);
|
||||||
/* To test premature reader exit >>>>>>>>>>>
|
/* To test premature reader exit >>>>>>>>>>>
|
||||||
iso_ring_buffer_reader_close(data->rbuf);
|
iso_ring_buffer_reader_close(data->rbuf);
|
||||||
pthread_exit(NULL);
|
pthread_exit(NULL);
|
||||||
<<<<<<<<<<<<<<<<<<<<<<<<< */
|
<<<<<<<<<<<<<<<<<<<<<<<<< */
|
||||||
// if (rand() > 2000000000) {
|
// if (rand() > 2000000000) {
|
||||||
// fprintf(stderr, "Reader sleeping\n");
|
// fprintf(stderr, "Reader sleeping\n");
|
||||||
// sleep(1);
|
// sleep(1);
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
fprintf(stderr, "Reader finish: %d\n", res);
|
fprintf(stderr, "Reader finish: %d\n", res);
|
||||||
|
|
||||||
@ -118,8 +119,8 @@ int main(int argc, char **argv)
|
|||||||
pthread_join(reader, NULL);
|
pthread_join(reader, NULL);
|
||||||
|
|
||||||
fprintf(stderr, "Buffer was %d times full and %d times empty.\n",
|
fprintf(stderr, "Buffer was %d times full and %d times empty.\n",
|
||||||
iso_ring_buffer_get_times_full(data.rbuf),
|
iso_ring_buffer_get_times_full(data.rbuf),
|
||||||
iso_ring_buffer_get_times_empty(data.rbuf));
|
iso_ring_buffer_get_times_empty(data.rbuf));
|
||||||
|
|
||||||
free(data.rbuf);
|
free(data.rbuf);
|
||||||
return 0;
|
return 0;
|
||||||
|
91
doc/devel/codestyle.xml
Normal file
91
doc/devel/codestyle.xml
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<profiles version="1">
|
||||||
|
<profile kind="CodeFormatterProfile" name="nglibisofs" version="1">
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.continuation_indentation" value="2"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.insert_new_line_in_empty_block" value="insert"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.lineSplit" value="80"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.keep_else_statement_on_same_line" value="false"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.alignment_for_conditional_expression" value="16"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.indent_switchstatements_compare_to_switch" value="false"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="insert"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_if" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.format_guardian_clause_on_one_line" value="false"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.indent_access_specifier_compare_to_type_header" value="false"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.indent_body_declarations_compare_to_access_specifier" value="true"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.indent_body_declarations_compare_to_namespace_header" value="false"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_colon_in_case" value="insert"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="insert"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.alignment_for_expressions_in_array_initializer" value="16"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_for" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.tabulation.size" value="4"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.insert_new_line_before_else_in_if_statement" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.indent_statements_compare_to_body" value="true"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.indent_statements_compare_to_block" value="true"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.indent_empty_lines" value="false"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.tabulation.char" value="space"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.keep_empty_array_initializer_on_one_line" value="false"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.put_empty_statement_on_new_line" value="true"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.brace_position_for_method_declaration" value="next_line"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.brace_position_for_block_in_case" value="next_line_shifted"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.compact_else_if" value="true"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_semicolon" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.keep_then_statement_on_same_line" value="false"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.brace_position_for_switch" value="end_of_line"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.indent_breaks_compare_to_cases" value="true"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.alignment_for_arguments_in_method_invocation" value="18"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_switch" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.alignment_for_parameters_in_method_declaration" value="18"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.keep_imple_if_on_one_line" value="false"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.indentation.size" value="4"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.brace_position_for_namespace_declaration" value="end_of_line"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.number_of_empty_lines_to_preserve" value="1"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.brace_position_for_array_initializer" value="end_of_line"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_namespace_declaration" value="insert"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.insert_new_line_before_while_in_do_statement" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="insert"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.brace_position_for_block" value="end_of_line"/>
|
||||||
|
<setting id="org.eclipse.cdt.core.formatter.brace_position_for_type_declaration" value="next_line"/>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
@ -28,7 +28,8 @@
|
|||||||
# define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
# define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct iso_ring_buffer {
|
struct iso_ring_buffer
|
||||||
|
{
|
||||||
uint8_t buf[BLOCK_SIZE * BUFFER_SIZE];
|
uint8_t buf[BLOCK_SIZE * BUFFER_SIZE];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -41,8 +42,8 @@ struct iso_ring_buffer {
|
|||||||
size_t wpos;
|
size_t wpos;
|
||||||
|
|
||||||
/* flags to report if read or writer threads ends execution */
|
/* flags to report if read or writer threads ends execution */
|
||||||
unsigned int rend:1;
|
unsigned int rend :1;
|
||||||
unsigned int wend:1;
|
unsigned int wend :1;
|
||||||
|
|
||||||
/* just for statistical purposes */
|
/* just for statistical purposes */
|
||||||
unsigned int times_full;
|
unsigned int times_full;
|
||||||
|
@ -73,7 +73,8 @@ size_t calc_dirent_len(Ecma119Image *t, Ecma119Node *n)
|
|||||||
if (need_version_number(t, n)) {
|
if (need_version_number(t, n)) {
|
||||||
ret += 2; /* take into account version numbers */
|
ret += 2; /* take into account version numbers */
|
||||||
}
|
}
|
||||||
if (ret % 2) ret++;
|
if (ret % 2)
|
||||||
|
ret++;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,8 +111,7 @@ size_t calc_dir_size(Ecma119Image *t, Ecma119Node *dir, size_t *ce)
|
|||||||
Ecma119Node *child = dir->info.dir.children[i];
|
Ecma119Node *child = dir->info.dir.children[i];
|
||||||
size_t dirent_len = calc_dirent_len(t, child);
|
size_t dirent_len = calc_dirent_len(t, child);
|
||||||
if (t->rockridge) {
|
if (t->rockridge) {
|
||||||
dirent_len += rrip_calc_len(t, child, 0, 255 - dirent_len,
|
dirent_len += rrip_calc_len(t, child, 0, 255 - dirent_len, &ce_len);
|
||||||
&ce_len);
|
|
||||||
*ce += ce_len;
|
*ce += ce_len;
|
||||||
}
|
}
|
||||||
remaining = BLOCK_SIZE - (len % BLOCK_SIZE);
|
remaining = BLOCK_SIZE - (len % BLOCK_SIZE);
|
||||||
@ -218,13 +218,13 @@ int ecma119_writer_compute_data_blocks(IsoImageWriter *writer)
|
|||||||
*/
|
*/
|
||||||
static
|
static
|
||||||
void write_one_dir_record(Ecma119Image *t, Ecma119Node *node, int file_id,
|
void write_one_dir_record(Ecma119Image *t, Ecma119Node *node, int file_id,
|
||||||
uint8_t *buf, size_t len_fi, struct susp_info *info)
|
uint8_t *buf, size_t len_fi, struct susp_info *info)
|
||||||
{
|
{
|
||||||
uint32_t len;
|
uint32_t len;
|
||||||
uint32_t block;
|
uint32_t block;
|
||||||
uint8_t len_dr; /*< size of dir entry without SUSP fields */
|
uint8_t len_dr; /*< size of dir entry without SUSP fields */
|
||||||
uint8_t *name = (file_id >= 0) ? (uint8_t*)&file_id :
|
uint8_t *name = (file_id >= 0) ? (uint8_t*)&file_id
|
||||||
(uint8_t*)node->iso_name;
|
: (uint8_t*)node->iso_name;
|
||||||
|
|
||||||
struct ecma119_dir_record *rec = (struct ecma119_dir_record*)buf;
|
struct ecma119_dir_record *rec = (struct ecma119_dir_record*)buf;
|
||||||
|
|
||||||
@ -433,7 +433,7 @@ int write_one_dir(Ecma119Image *t, Ecma119Node *dir)
|
|||||||
len += info.suf_len;
|
len += info.suf_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (buf + len - buffer) > BLOCK_SIZE ) {
|
if ( (buf + len - buffer) > BLOCK_SIZE) {
|
||||||
/* dir doesn't fit in current block */
|
/* dir doesn't fit in current block */
|
||||||
ret = iso_write(t, buffer, BLOCK_SIZE);
|
ret = iso_write(t, buffer, BLOCK_SIZE);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
@ -496,7 +496,7 @@ int write_path_table(Ecma119Image *t, Ecma119Node **pathlist, int l_type)
|
|||||||
Ecma119Node *dir;
|
Ecma119Node *dir;
|
||||||
uint32_t path_table_size;
|
uint32_t path_table_size;
|
||||||
int parent = 0;
|
int parent = 0;
|
||||||
int ret = ISO_SUCCESS;
|
int ret= ISO_SUCCESS;
|
||||||
|
|
||||||
path_table_size = 0;
|
path_table_size = 0;
|
||||||
write_int = l_type ? iso_lsb : iso_msb;
|
write_int = l_type ? iso_lsb : iso_msb;
|
||||||
@ -575,7 +575,7 @@ int write_path_tables(Ecma119Image *t)
|
|||||||
/* Write L Path Table */
|
/* Write L Path Table */
|
||||||
ret = write_path_table(t, pathlist, 0);
|
ret = write_path_table(t, pathlist, 0);
|
||||||
|
|
||||||
write_path_tables_exit:;
|
write_path_tables_exit: ;
|
||||||
free(pathlist);
|
free(pathlist);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -702,7 +702,7 @@ void *write_function(void *arg)
|
|||||||
iso_ring_buffer_writer_close(target->buffer);
|
iso_ring_buffer_writer_close(target->buffer);
|
||||||
pthread_exit(NULL);
|
pthread_exit(NULL);
|
||||||
|
|
||||||
write_error:;
|
write_error: ;
|
||||||
iso_msg_fatal(target->image, LIBISO_WRITE_ERROR,
|
iso_msg_fatal(target->image, LIBISO_WRITE_ERROR,
|
||||||
"Image write error, code %d", res);
|
"Image write error, code %d", res);
|
||||||
iso_ring_buffer_writer_close(target->buffer);
|
iso_ring_buffer_writer_close(target->buffer);
|
||||||
@ -710,8 +710,7 @@ write_error:;
|
|||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
int ecma119_image_new(IsoImage *src, Ecma119WriteOpts *opts,
|
int ecma119_image_new(IsoImage *src, Ecma119WriteOpts *opts, Ecma119Image **img)
|
||||||
Ecma119Image **img)
|
|
||||||
{
|
{
|
||||||
int ret, i;
|
int ret, i;
|
||||||
Ecma119Image *target;
|
Ecma119Image *target;
|
||||||
@ -857,13 +856,12 @@ int ecma119_image_new(IsoImage *src, Ecma119WriteOpts *opts,
|
|||||||
*img = target;
|
*img = target;
|
||||||
return ISO_SUCCESS;
|
return ISO_SUCCESS;
|
||||||
|
|
||||||
target_cleanup:;
|
target_cleanup: ;
|
||||||
ecma119_image_free(target);
|
ecma119_image_free(target);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int bs_read(struct burn_source *bs, unsigned char *buf, int size)
|
||||||
bs_read(struct burn_source *bs, unsigned char *buf, int size)
|
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
Ecma119Image *t = (Ecma119Image*)bs->data;
|
Ecma119Image *t = (Ecma119Image*)bs->data;
|
||||||
@ -881,15 +879,13 @@ bs_read(struct burn_source *bs, unsigned char *buf, int size)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static off_t
|
static off_t bs_get_size(struct burn_source *bs)
|
||||||
bs_get_size(struct burn_source *bs)
|
|
||||||
{
|
{
|
||||||
Ecma119Image *target = (Ecma119Image*)bs->data;
|
Ecma119Image *target = (Ecma119Image*)bs->data;
|
||||||
return target->total_size;
|
return target->total_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void bs_free_data(struct burn_source *bs)
|
||||||
bs_free_data(struct burn_source *bs)
|
|
||||||
{
|
{
|
||||||
Ecma119Image *target = (Ecma119Image*)bs->data;
|
Ecma119Image *target = (Ecma119Image*)bs->data;
|
||||||
|
|
||||||
@ -927,7 +923,7 @@ int iso_image_create(IsoImage *image, Ecma119WriteOpts *opts,
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
struct burn_source *source;
|
struct burn_source *source;
|
||||||
Ecma119Image *target = NULL;
|
Ecma119Image *target= NULL;
|
||||||
|
|
||||||
if (image == NULL || opts == NULL || burn_src == NULL) {
|
if (image == NULL || opts == NULL || burn_src == NULL) {
|
||||||
return ISO_NULL_POINTER;
|
return ISO_NULL_POINTER;
|
||||||
|
@ -23,36 +23,39 @@ typedef struct ecma119_node Ecma119Node;
|
|||||||
typedef struct Iso_File_Src IsoFileSrc;
|
typedef struct Iso_File_Src IsoFileSrc;
|
||||||
typedef struct Iso_Image_Writer IsoImageWriter;
|
typedef struct Iso_Image_Writer IsoImageWriter;
|
||||||
|
|
||||||
struct ecma119_image {
|
struct ecma119_image
|
||||||
|
{
|
||||||
IsoImage *image;
|
IsoImage *image;
|
||||||
Ecma119Node *root;
|
Ecma119Node *root;
|
||||||
|
|
||||||
unsigned int iso_level:2;
|
unsigned int iso_level :2;
|
||||||
|
|
||||||
/* extensions */
|
/* extensions */
|
||||||
unsigned int rockridge:1;
|
unsigned int rockridge :1;
|
||||||
|
|
||||||
/* relaxed constraints */
|
/* relaxed constraints */
|
||||||
unsigned int omit_version_numbers:1;
|
unsigned int omit_version_numbers :1;
|
||||||
unsigned int allow_deep_paths:1;
|
unsigned int allow_deep_paths :1;
|
||||||
// int relaxed_constraints; /**< see ecma119_relaxed_constraints_flag */
|
// int relaxed_constraints; /**< see ecma119_relaxed_constraints_flag */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mode replace. If one of these flags is set, the correspodent values are
|
* Mode replace. If one of these flags is set, the correspodent values are
|
||||||
* replaced with values below.
|
* replaced with values below.
|
||||||
*/
|
*/
|
||||||
unsigned int replace_uid:1;
|
unsigned int replace_uid :1;
|
||||||
unsigned int replace_gid:1;
|
unsigned int replace_gid :1;
|
||||||
unsigned int replace_file_mode:1;
|
unsigned int replace_file_mode :1;
|
||||||
unsigned int replace_dir_mode:1;
|
unsigned int replace_dir_mode :1;
|
||||||
|
|
||||||
uid_t uid;
|
uid_t uid;
|
||||||
gid_t gid;
|
gid_t gid;
|
||||||
mode_t file_mode;
|
mode_t file_mode;
|
||||||
mode_t dir_mode;
|
mode_t dir_mode;
|
||||||
|
|
||||||
int sort_files; /**< if sort files or not. Sorting is based of
|
/**
|
||||||
* the weight of each file */
|
* if sort files or not. Sorting is based of the weight of each file
|
||||||
|
*/
|
||||||
|
int sort_files;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In the CD, each file must have an unique inode number. So each
|
* In the CD, each file must have an unique inode number. So each
|
||||||
@ -64,9 +67,10 @@ struct ecma119_image {
|
|||||||
char *output_charset;
|
char *output_charset;
|
||||||
|
|
||||||
uint32_t ms_block; /**< start block for a ms image */
|
uint32_t ms_block; /**< start block for a ms image */
|
||||||
time_t now; /**< Time at which writing began. */
|
time_t now; /**< Time at which writing began. */
|
||||||
off_t total_size; /**< Total size of the output. This only
|
|
||||||
* includes the current volume. */
|
/** Total size of the output. This only includes the current volume. */
|
||||||
|
off_t total_size;
|
||||||
uint32_t vol_space_size;
|
uint32_t vol_space_size;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -25,7 +25,7 @@ int get_iso_name(Ecma119Image *img, IsoNode *iso, char **name)
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
char *ascii_name;
|
char *ascii_name;
|
||||||
char *isoname = NULL;
|
char *isoname= NULL;
|
||||||
|
|
||||||
if (iso->name == NULL) {
|
if (iso->name == NULL) {
|
||||||
/* it is not necessarily an error, it can be the root */
|
/* it is not necessarily an error, it can be the root */
|
||||||
@ -128,7 +128,7 @@ int create_file(Ecma119Image *img, IsoFile *iso, Ecma119Node **node)
|
|||||||
if (size > (off_t)0xffffffff) {
|
if (size > (off_t)0xffffffff) {
|
||||||
iso_msg_note(img->image, LIBISO_FILE_IGNORED,
|
iso_msg_note(img->image, LIBISO_FILE_IGNORED,
|
||||||
"File \"%s\" can't be added to image because is "
|
"File \"%s\" can't be added to image because is "
|
||||||
"greater than 4GB", iso->node.name);
|
"greater than 4GB", iso->node.name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,7 +214,7 @@ int create_tree(Ecma119Image *image, IsoNode *iso, Ecma119Node **tree,
|
|||||||
int ret;
|
int ret;
|
||||||
Ecma119Node *node;
|
Ecma119Node *node;
|
||||||
int max_path;
|
int max_path;
|
||||||
char *iso_name = NULL;
|
char *iso_name= NULL;
|
||||||
|
|
||||||
if (image == NULL || iso == NULL || tree == NULL) {
|
if (image == NULL || iso == NULL || tree == NULL) {
|
||||||
return ISO_NULL_POINTER;
|
return ISO_NULL_POINTER;
|
||||||
@ -233,13 +233,13 @@ int create_tree(Ecma119Image *image, IsoNode *iso, Ecma119Node **tree,
|
|||||||
if ((iso->type == LIBISO_DIR && depth > 8) || max_path > 255) {
|
if ((iso->type == LIBISO_DIR && depth > 8) || max_path > 255) {
|
||||||
iso_msg_note(image->image, LIBISO_FILE_IGNORED,
|
iso_msg_note(image->image, LIBISO_FILE_IGNORED,
|
||||||
"File \"%s\" can't be added, because depth > 8 "
|
"File \"%s\" can't be added, because depth > 8 "
|
||||||
"or path length over 255", iso->name);
|
"or path length over 255", iso->name);
|
||||||
free(iso_name);
|
free(iso_name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(iso->type) {
|
switch (iso->type) {
|
||||||
case LIBISO_FILE:
|
case LIBISO_FILE:
|
||||||
ret = create_file(image, (IsoFile*)iso, &node);
|
ret = create_file(image, (IsoFile*)iso, &node);
|
||||||
break;
|
break;
|
||||||
@ -249,8 +249,7 @@ int create_tree(Ecma119Image *image, IsoNode *iso, Ecma119Node **tree,
|
|||||||
} else {
|
} else {
|
||||||
/* symlinks are only supported when RR is enabled */
|
/* symlinks are only supported when RR is enabled */
|
||||||
iso_msg_note(image->image, LIBISO_FILE_IGNORED, "File \"%s\" "
|
iso_msg_note(image->image, LIBISO_FILE_IGNORED, "File \"%s\" "
|
||||||
"ignored. Symlinks need RockRidge extensions.",
|
"ignored. Symlinks need RockRidge extensions.", iso->name);
|
||||||
iso->name);
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -260,8 +259,7 @@ int create_tree(Ecma119Image *image, IsoNode *iso, Ecma119Node **tree,
|
|||||||
} else {
|
} else {
|
||||||
/* symlinks are only supported when RR is enabled */
|
/* symlinks are only supported when RR is enabled */
|
||||||
iso_msg_note(image->image, LIBISO_FILE_IGNORED, "File \"%s\" "
|
iso_msg_note(image->image, LIBISO_FILE_IGNORED, "File \"%s\" "
|
||||||
"ignored. Special files need RockRidge extensions.",
|
"ignored. Special files need RockRidge extensions.", iso->name);
|
||||||
iso->name);
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -331,8 +329,8 @@ void sort_tree(Ecma119Node *root)
|
|||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
qsort(root->info.dir.children, root->info.dir.nchildren,
|
qsort(root->info.dir.children, root->info.dir.nchildren, sizeof(void*),
|
||||||
sizeof(void*), cmp_node_name);
|
cmp_node_name);
|
||||||
for (i = 0; i < root->info.dir.nchildren; i++) {
|
for (i = 0; i < root->info.dir.nchildren; i++) {
|
||||||
if (root->info.dir.children[i]->type == ECMA119_DIR)
|
if (root->info.dir.children[i]->type == ECMA119_DIR)
|
||||||
sort_tree(root->info.dir.children[i]);
|
sort_tree(root->info.dir.children[i]);
|
||||||
@ -361,7 +359,7 @@ int contains_name(Ecma119Node *dir, const char *name)
|
|||||||
*/
|
*/
|
||||||
static
|
static
|
||||||
int mangle_single_dir(Ecma119Image *img, Ecma119Node *dir, int max_file_len,
|
int mangle_single_dir(Ecma119Image *img, Ecma119Node *dir, int max_file_len,
|
||||||
int max_dir_len)
|
int max_dir_len)
|
||||||
{
|
{
|
||||||
int i, nchildren;
|
int i, nchildren;
|
||||||
Ecma119Node **children;
|
Ecma119Node **children;
|
||||||
@ -378,8 +376,8 @@ int mangle_single_dir(Ecma119Image *img, Ecma119Node *dir, int max_file_len,
|
|||||||
int digits = 1; /* characters to change per name */
|
int digits = 1; /* characters to change per name */
|
||||||
|
|
||||||
/* first, find all child with same name */
|
/* first, find all child with same name */
|
||||||
while (j + 1 < nchildren &&
|
while (j + 1 < nchildren && !cmp_node_name(children + i, children + j
|
||||||
!cmp_node_name(children + i, children + j + 1)) {
|
+ 1)) {
|
||||||
++j;
|
++j;
|
||||||
}
|
}
|
||||||
if (j == i) {
|
if (j == i) {
|
||||||
@ -538,8 +536,8 @@ int mangle_dir(Ecma119Image *img, Ecma119Node *dir, int max_file_len,
|
|||||||
/* recurse */
|
/* recurse */
|
||||||
for (i = 0; i < dir->info.dir.nchildren; ++i) {
|
for (i = 0; i < dir->info.dir.nchildren; ++i) {
|
||||||
if (dir->info.dir.children[i]->type == ECMA119_DIR) {
|
if (dir->info.dir.children[i]->type == ECMA119_DIR) {
|
||||||
ret = mangle_dir(img, dir->info.dir.children[i],
|
ret = mangle_dir(img, dir->info.dir.children[i], max_file_len,
|
||||||
max_file_len, max_dir_len);
|
max_dir_len);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
/* error */
|
/* error */
|
||||||
return ret;
|
return ret;
|
||||||
@ -575,8 +573,8 @@ int mangle_tree(Ecma119Image *img, int recurse)
|
|||||||
* See IEEE P1282, section 4.1.5 for details
|
* See IEEE P1282, section 4.1.5 for details
|
||||||
*/
|
*/
|
||||||
static
|
static
|
||||||
int create_placeholder(Ecma119Node *parent,
|
int create_placeholder(Ecma119Node *parent, Ecma119Node *real,
|
||||||
Ecma119Node *real, Ecma119Node **node)
|
Ecma119Node **node)
|
||||||
{
|
{
|
||||||
Ecma119Node *ret;
|
Ecma119Node *ret;
|
||||||
|
|
||||||
@ -634,7 +632,7 @@ int reparent(Ecma119Node *child, Ecma119Node *parent)
|
|||||||
Ecma119Node *placeholder;
|
Ecma119Node *placeholder;
|
||||||
|
|
||||||
/* replace the child in the original parent with a placeholder */
|
/* replace the child in the original parent with a placeholder */
|
||||||
for ( i = 0; i < child->parent->info.dir.nchildren; i++) {
|
for (i = 0; i < child->parent->info.dir.nchildren; i++) {
|
||||||
if (child->parent->info.dir.children[i] == child) {
|
if (child->parent->info.dir.children[i] == child) {
|
||||||
ret = create_placeholder(child->parent, child, &placeholder);
|
ret = create_placeholder(child->parent, child, &placeholder);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
@ -656,8 +654,8 @@ int reparent(Ecma119Node *child, Ecma119Node *parent)
|
|||||||
/* add the child to its new parent */
|
/* add the child to its new parent */
|
||||||
child->parent = parent;
|
child->parent = parent;
|
||||||
parent->info.dir.nchildren++;
|
parent->info.dir.nchildren++;
|
||||||
parent->info.dir.children = realloc( parent->info.dir.children,
|
parent->info.dir.children = realloc(parent->info.dir.children,
|
||||||
sizeof(void*) * parent->info.dir.nchildren );
|
sizeof(void*) * parent->info.dir.nchildren);
|
||||||
parent->info.dir.children[parent->info.dir.nchildren - 1] = child;
|
parent->info.dir.children[parent->info.dir.nchildren - 1] = child;
|
||||||
return ISO_SUCCESS;
|
return ISO_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,8 @@ enum ecma119_node_type {
|
|||||||
/**
|
/**
|
||||||
* Struct with info about a node representing a tree
|
* Struct with info about a node representing a tree
|
||||||
*/
|
*/
|
||||||
struct ecma119_dir_info {
|
struct ecma119_dir_info
|
||||||
|
{
|
||||||
/* Block where the directory entries will be written on image */
|
/* Block where the directory entries will be written on image */
|
||||||
size_t block;
|
size_t block;
|
||||||
|
|
||||||
@ -67,7 +68,8 @@ struct ecma119_node
|
|||||||
|
|
||||||
/**< file, symlink, special, directory or placeholder */
|
/**< file, symlink, special, directory or placeholder */
|
||||||
enum ecma119_node_type type;
|
enum ecma119_node_type type;
|
||||||
union {
|
union
|
||||||
|
{
|
||||||
IsoFileSrc *file;
|
IsoFileSrc *file;
|
||||||
// TODO this wastes too much memory, as dirs have much more
|
// TODO this wastes too much memory, as dirs have much more
|
||||||
// atts than other kind of files. Replace with a pointer.
|
// atts than other kind of files. Replace with a pointer.
|
||||||
|
@ -44,8 +44,7 @@ int iso_file_src_cmp(const void *n1, const void *n2)
|
|||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
/* files belong to same device in same fs */
|
/* files belong to same device in same fs */
|
||||||
return (ino_id1 < ino_id2) ? -1 :
|
return (ino_id1 < ino_id2) ? -1 : (ino_id1 > ino_id2) ? 1 : 0;
|
||||||
(ino_id1 > ino_id2) ? 1 : 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -105,8 +104,7 @@ off_t iso_file_src_get_size(IsoFileSrc *file)
|
|||||||
return iso_stream_get_size(file->stream);
|
return iso_stream_get_size(file->stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int cmp_by_weight(const void *f1, const void *f2)
|
||||||
cmp_by_weight(const void *f1, const void *f2)
|
|
||||||
{
|
{
|
||||||
IsoFileSrc *f = *((IsoFileSrc**)f1);
|
IsoFileSrc *f = *((IsoFileSrc**)f1);
|
||||||
IsoFileSrc *g = *((IsoFileSrc**)f2);
|
IsoFileSrc *g = *((IsoFileSrc**)f2);
|
||||||
@ -137,7 +135,7 @@ int filesrc_writer_compute_data_blocks(IsoImageWriter *writer)
|
|||||||
|
|
||||||
/* sort files by weight, if needed */
|
/* sort files by weight, if needed */
|
||||||
if (t->sort_files) {
|
if (t->sort_files) {
|
||||||
qsort(t->files, size, sizeof(void*), cmp_by_weight);
|
qsort(t->files, size, sizeof(void*), cmp_by_weight);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* fill block value */
|
/* fill block value */
|
||||||
@ -239,18 +237,18 @@ int filesrc_writer_write_data(IsoImageWriter *writer)
|
|||||||
* UPS, very ugly error, the best we can do is just to write
|
* UPS, very ugly error, the best we can do is just to write
|
||||||
* 0's to image
|
* 0's to image
|
||||||
*/
|
*/
|
||||||
// TODO Stream needs a get_path function
|
// TODO Stream needs a get_path function
|
||||||
iso_msg_sorry(t->image, LIBISO_FILE_CANT_WRITE,
|
iso_msg_sorry(t->image, LIBISO_FILE_CANT_WRITE,
|
||||||
"File XXX can't be openned. Filling with 0s.");
|
"File XXX can't be openned. Filling with 0s.");
|
||||||
memset(buffer, 0, BLOCK_SIZE);
|
memset(buffer, 0, BLOCK_SIZE);
|
||||||
for (b = 0; b < nblocks; ++b) {
|
for (b = 0; b < nblocks; ++b) {
|
||||||
res = iso_write(t, buffer, BLOCK_SIZE);
|
res = iso_write(t, buffer, BLOCK_SIZE);
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
/* ko, writer error, we need to go out! */
|
/* ko, writer error, we need to go out! */
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* write file contents to image */
|
/* write file contents to image */
|
||||||
|
@ -14,8 +14,9 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
struct Iso_File_Src {
|
struct Iso_File_Src
|
||||||
unsigned int prev_img:1; /**< if the file comes from a previous image */
|
{
|
||||||
|
unsigned int prev_img :1; /**< if the file comes from a previous image */
|
||||||
uint32_t block; /**< Block where this file will be written on image */
|
uint32_t block; /**< Block where this file will be written on image */
|
||||||
int sort_weight;
|
int sort_weight;
|
||||||
IsoStream *stream;
|
IsoStream *stream;
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
* published by the Free Software Foundation. See COPYING file for details.
|
* published by the Free Software Foundation. See COPYING file for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Filesystem/FileSource implementation to access the local filesystem.
|
* Filesystem/FileSource implementation to access the local filesystem.
|
||||||
*/
|
*/
|
||||||
@ -29,15 +28,16 @@
|
|||||||
/*
|
/*
|
||||||
* We can share a local filesystem object, as it has no private atts.
|
* We can share a local filesystem object, as it has no private atts.
|
||||||
*/
|
*/
|
||||||
IsoFilesystem *lfs = NULL;
|
IsoFilesystem *lfs= NULL;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
/* IsoFilesystem *fs; It seems not needed */
|
/* IsoFilesystem *fs; It seems not needed */
|
||||||
|
|
||||||
char *path;
|
char *path;
|
||||||
unsigned int openned:2; /* 0: not openned, 1: file, 2:dir */
|
unsigned int openned :2; /* 0: not openned, 1: file, 2:dir */
|
||||||
union {
|
union
|
||||||
|
{
|
||||||
int fd;
|
int fd;
|
||||||
DIR *dir;
|
DIR *dir;
|
||||||
} info;
|
} info;
|
||||||
@ -77,7 +77,7 @@ int lfs_lstat(IsoFileSource *src, struct stat *info)
|
|||||||
int err;
|
int err;
|
||||||
|
|
||||||
/* error, choose an appropriate return code */
|
/* error, choose an appropriate return code */
|
||||||
switch(errno) {
|
switch (errno) {
|
||||||
case EACCES:
|
case EACCES:
|
||||||
err = ISO_FILE_ACCESS_DENIED;
|
err = ISO_FILE_ACCESS_DENIED;
|
||||||
break;
|
break;
|
||||||
@ -116,7 +116,7 @@ int lfs_stat(IsoFileSource *src, struct stat *info)
|
|||||||
int err;
|
int err;
|
||||||
|
|
||||||
/* error, choose an appropriate return code */
|
/* error, choose an appropriate return code */
|
||||||
switch(errno) {
|
switch (errno) {
|
||||||
case EACCES:
|
case EACCES:
|
||||||
err = ISO_FILE_ACCESS_DENIED;
|
err = ISO_FILE_ACCESS_DENIED;
|
||||||
break;
|
break;
|
||||||
@ -176,7 +176,7 @@ int lfs_open(IsoFileSource *src)
|
|||||||
* parsed in the lstat call above
|
* parsed in the lstat call above
|
||||||
*/
|
*/
|
||||||
if (data->openned == 0) {
|
if (data->openned == 0) {
|
||||||
switch(errno) {
|
switch (errno) {
|
||||||
case EACCES:
|
case EACCES:
|
||||||
err = ISO_FILE_ACCESS_DENIED;
|
err = ISO_FILE_ACCESS_DENIED;
|
||||||
break;
|
break;
|
||||||
@ -205,7 +205,7 @@ int lfs_close(IsoFileSource *src)
|
|||||||
}
|
}
|
||||||
|
|
||||||
data = src->data;
|
data = src->data;
|
||||||
switch(data->openned) {
|
switch (data->openned) {
|
||||||
case 1: /* not dir */
|
case 1: /* not dir */
|
||||||
ret = close(data->info.fd) == 0 ? ISO_SUCCESS : ISO_FILE_ERROR;
|
ret = close(data->info.fd) == 0 ? ISO_SUCCESS : ISO_FILE_ERROR;
|
||||||
break;
|
break;
|
||||||
@ -232,14 +232,14 @@ int lfs_read(IsoFileSource *src, void *buf, size_t count)
|
|||||||
}
|
}
|
||||||
|
|
||||||
data = src->data;
|
data = src->data;
|
||||||
switch(data->openned) {
|
switch (data->openned) {
|
||||||
case 1: /* not dir */
|
case 1: /* not dir */
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
ret = read(data->info.fd, buf, count);
|
ret = read(data->info.fd, buf, count);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
/* error on read */
|
/* error on read */
|
||||||
switch(errno) {
|
switch (errno) {
|
||||||
case EINTR:
|
case EINTR:
|
||||||
ret = ISO_INTERRUPTED;
|
ret = ISO_INTERRUPTED;
|
||||||
break;
|
break;
|
||||||
@ -273,7 +273,7 @@ int lfs_readdir(IsoFileSource *src, IsoFileSource **child)
|
|||||||
}
|
}
|
||||||
|
|
||||||
data = src->data;
|
data = src->data;
|
||||||
switch(data->openned) {
|
switch (data->openned) {
|
||||||
case 1: /* not dir */
|
case 1: /* not dir */
|
||||||
return ISO_FILE_IS_NOT_DIR;
|
return ISO_FILE_IS_NOT_DIR;
|
||||||
case 2: /* directory */
|
case 2: /* directory */
|
||||||
@ -292,7 +292,7 @@ int lfs_readdir(IsoFileSource *src, IsoFileSource **child)
|
|||||||
else
|
else
|
||||||
return 0; /* EOF */
|
return 0; /* EOF */
|
||||||
}
|
}
|
||||||
if (strcmp(entry->d_name,".") && strcmp(entry->d_name,"..")) {
|
if (strcmp(entry->d_name, ".") && strcmp(entry->d_name, "..")) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -342,7 +342,7 @@ int lfs_readlink(IsoFileSource *src, char *buf, size_t bufsiz)
|
|||||||
size = readlink(data->path, buf, bufsiz - 1);
|
size = readlink(data->path, buf, bufsiz - 1);
|
||||||
if (size < 0) {
|
if (size < 0) {
|
||||||
/* error */
|
/* error */
|
||||||
switch(errno) {
|
switch (errno) {
|
||||||
case EACCES:
|
case EACCES:
|
||||||
return ISO_FILE_ACCESS_DENIED;
|
return ISO_FILE_ACCESS_DENIED;
|
||||||
case ENOTDIR:
|
case ENOTDIR:
|
||||||
@ -462,19 +462,19 @@ int iso_file_source_new_lfs(const char *path, IsoFileSource **src)
|
|||||||
static
|
static
|
||||||
int lfs_get_root(IsoFilesystem *fs, IsoFileSource **root)
|
int lfs_get_root(IsoFilesystem *fs, IsoFileSource **root)
|
||||||
{
|
{
|
||||||
if (fs == NULL || root == NULL) {
|
if (fs == NULL || root == NULL) {
|
||||||
return ISO_NULL_POINTER;
|
return ISO_NULL_POINTER;
|
||||||
}
|
}
|
||||||
return iso_file_source_new_lfs("/", root);
|
return iso_file_source_new_lfs("/", root);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
int lfs_get_by_path(IsoFilesystem *fs, const char *path, IsoFileSource **file)
|
int lfs_get_by_path(IsoFilesystem *fs, const char *path, IsoFileSource **file)
|
||||||
{
|
{
|
||||||
if (fs == NULL || path == NULL || file == NULL) {
|
if (fs == NULL || path == NULL || file == NULL) {
|
||||||
return ISO_NULL_POINTER;
|
return ISO_NULL_POINTER;
|
||||||
}
|
}
|
||||||
return iso_file_source_new_lfs(path, file);
|
return iso_file_source_new_lfs(path, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
@ -486,12 +486,12 @@ unsigned int lfs_get_id(IsoFilesystem *fs)
|
|||||||
static
|
static
|
||||||
void lfs_fs_free(IsoFilesystem *fs)
|
void lfs_fs_free(IsoFilesystem *fs)
|
||||||
{
|
{
|
||||||
lfs = NULL;
|
lfs = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int iso_local_filesystem_new(IsoFilesystem **fs)
|
int iso_local_filesystem_new(IsoFilesystem **fs)
|
||||||
{
|
{
|
||||||
if (fs == NULL) {
|
if (fs == NULL) {
|
||||||
return ISO_NULL_POINTER;
|
return ISO_NULL_POINTER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -500,7 +500,7 @@ int iso_local_filesystem_new(IsoFilesystem **fs)
|
|||||||
iso_filesystem_ref(lfs);
|
iso_filesystem_ref(lfs);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
lfs = malloc(sizeof(IsoFilesystem));
|
lfs = malloc(sizeof(IsoFilesystem));
|
||||||
if (lfs == NULL) {
|
if (lfs == NULL) {
|
||||||
return ISO_OUT_OF_MEM;
|
return ISO_OUT_OF_MEM;
|
||||||
}
|
}
|
||||||
@ -513,6 +513,6 @@ int iso_local_filesystem_new(IsoFilesystem **fs)
|
|||||||
lfs->get_id = lfs_get_id;
|
lfs->get_id = lfs_get_id;
|
||||||
lfs->free = lfs_fs_free;
|
lfs->free = lfs_fs_free;
|
||||||
}
|
}
|
||||||
*fs = lfs;
|
*fs = lfs;
|
||||||
return ISO_SUCCESS;
|
return ISO_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -16,26 +16,26 @@ unsigned int iso_fs_global_id = 100;
|
|||||||
|
|
||||||
void iso_file_source_ref(IsoFileSource *src)
|
void iso_file_source_ref(IsoFileSource *src)
|
||||||
{
|
{
|
||||||
++src->refcount;
|
++src->refcount;
|
||||||
}
|
}
|
||||||
|
|
||||||
void iso_file_source_unref(IsoFileSource *src)
|
void iso_file_source_unref(IsoFileSource *src)
|
||||||
{
|
{
|
||||||
if (--src->refcount == 0) {
|
if (--src->refcount == 0) {
|
||||||
src->class->free(src);
|
src->class->free(src);
|
||||||
free(src);
|
free(src);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void iso_filesystem_ref(IsoFilesystem *fs)
|
void iso_filesystem_ref(IsoFilesystem *fs)
|
||||||
{
|
{
|
||||||
++fs->refcount;
|
++fs->refcount;
|
||||||
}
|
}
|
||||||
|
|
||||||
void iso_filesystem_unref(IsoFilesystem *fs)
|
void iso_filesystem_unref(IsoFilesystem *fs)
|
||||||
{
|
{
|
||||||
if (--fs->refcount == 0) {
|
if (--fs->refcount == 0) {
|
||||||
fs->free(fs);
|
fs->free(fs);
|
||||||
free(fs);
|
free(fs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Some functions here will be moved to libisofs.h when we expose
|
* Some functions here will be moved to libisofs.h when we expose Sources.
|
||||||
* Sources.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@ -233,7 +232,8 @@ typedef struct IsoFileSource_Iface
|
|||||||
*/
|
*/
|
||||||
} IsoFileSourceIface;
|
} IsoFileSourceIface;
|
||||||
|
|
||||||
struct Iso_File_Source {
|
struct Iso_File_Source
|
||||||
|
{
|
||||||
const IsoFileSourceIface *class;
|
const IsoFileSourceIface *class;
|
||||||
int refcount;
|
int refcount;
|
||||||
void *data;
|
void *data;
|
||||||
@ -246,37 +246,44 @@ void iso_file_source_unref(IsoFileSource *src);
|
|||||||
* this are just helpers to invoque methods in class
|
* this are just helpers to invoque methods in class
|
||||||
*/
|
*/
|
||||||
extern inline
|
extern inline
|
||||||
const char* iso_file_source_get_path(IsoFileSource *src) {
|
const char* iso_file_source_get_path(IsoFileSource *src)
|
||||||
|
{
|
||||||
return src->class->get_path(src);
|
return src->class->get_path(src);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern inline
|
extern inline
|
||||||
char* iso_file_source_get_name(IsoFileSource *src) {
|
char* iso_file_source_get_name(IsoFileSource *src)
|
||||||
|
{
|
||||||
return src->class->get_name(src);
|
return src->class->get_name(src);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern inline
|
extern inline
|
||||||
int iso_file_source_lstat(IsoFileSource *src, struct stat *info) {
|
int iso_file_source_lstat(IsoFileSource *src, struct stat *info)
|
||||||
|
{
|
||||||
return src->class->lstat(src, info);
|
return src->class->lstat(src, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern inline
|
extern inline
|
||||||
int iso_file_source_stat(IsoFileSource *src, struct stat *info) {
|
int iso_file_source_stat(IsoFileSource *src, struct stat *info)
|
||||||
|
{
|
||||||
return src->class->stat(src, info);
|
return src->class->stat(src, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern inline
|
extern inline
|
||||||
int iso_file_source_open(IsoFileSource *src) {
|
int iso_file_source_open(IsoFileSource *src)
|
||||||
|
{
|
||||||
return src->class->open(src);
|
return src->class->open(src);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern inline
|
extern inline
|
||||||
int iso_file_source_close(IsoFileSource *src) {
|
int iso_file_source_close(IsoFileSource *src)
|
||||||
|
{
|
||||||
return src->class->close(src);
|
return src->class->close(src);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern inline
|
extern inline
|
||||||
int iso_file_source_read(IsoFileSource *src, void *buf, size_t count) {
|
int iso_file_source_read(IsoFileSource *src, void *buf, size_t count)
|
||||||
|
{
|
||||||
return src->class->read(src, buf, count);
|
return src->class->read(src, buf, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -287,12 +294,14 @@ int iso_file_source_readdir(IsoFileSource *src, IsoFileSource **child)
|
|||||||
}
|
}
|
||||||
|
|
||||||
extern inline
|
extern inline
|
||||||
int iso_file_source_readlink(IsoFileSource *src, char *buf, size_t bufsiz) {
|
int iso_file_source_readlink(IsoFileSource *src, char *buf, size_t bufsiz)
|
||||||
|
{
|
||||||
return src->class->readlink(src, buf, bufsiz);
|
return src->class->readlink(src, buf, bufsiz);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern inline
|
extern inline
|
||||||
IsoFilesystem* iso_file_source_get_filesystem(IsoFileSource *src) {
|
IsoFilesystem* iso_file_source_get_filesystem(IsoFileSource *src)
|
||||||
|
{
|
||||||
return src->class->get_filesystem(src);
|
return src->class->get_filesystem(src);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
11
src/image.c
11
src/image.c
@ -77,7 +77,7 @@ int iso_image_new(const char *name, IsoImage **image)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
img->refcount = 1;
|
img->refcount = 1;
|
||||||
img->recOpts = calloc(1,sizeof(IsoImageRecOpts));
|
img->recOpts = calloc(1, sizeof(IsoImageRecOpts));
|
||||||
if (img->recOpts == NULL) {
|
if (img->recOpts == NULL) {
|
||||||
libiso_msgs_destroy(&img->messenger, 0);
|
libiso_msgs_destroy(&img->messenger, 0);
|
||||||
iso_node_builder_unref(img->builder);
|
iso_node_builder_unref(img->builder);
|
||||||
@ -167,7 +167,7 @@ const char *iso_image_get_publisher_id(const IsoImage *image)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void iso_image_set_data_preparer_id(IsoImage *image,
|
void iso_image_set_data_preparer_id(IsoImage *image,
|
||||||
const char *data_preparer_id)
|
const char *data_preparer_id)
|
||||||
{
|
{
|
||||||
free(image->data_preparer_id);
|
free(image->data_preparer_id);
|
||||||
image->data_preparer_id = strdup(data_preparer_id);
|
image->data_preparer_id = strdup(data_preparer_id);
|
||||||
@ -201,7 +201,7 @@ const char *iso_image_get_application_id(const IsoImage *image)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void iso_image_set_copyright_file_id(IsoImage *image,
|
void iso_image_set_copyright_file_id(IsoImage *image,
|
||||||
const char *copyright_file_id)
|
const char *copyright_file_id)
|
||||||
{
|
{
|
||||||
free(image->copyright_file_id);
|
free(image->copyright_file_id);
|
||||||
image->copyright_file_id = strdup(copyright_file_id);
|
image->copyright_file_id = strdup(copyright_file_id);
|
||||||
@ -213,7 +213,7 @@ const char *iso_image_get_copyright_file_id(const IsoImage *image)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void iso_image_set_abstract_file_id(IsoImage *image,
|
void iso_image_set_abstract_file_id(IsoImage *image,
|
||||||
const char *abstract_file_id)
|
const char *abstract_file_id)
|
||||||
{
|
{
|
||||||
free(image->abstract_file_id);
|
free(image->abstract_file_id);
|
||||||
image->abstract_file_id = strdup(abstract_file_id);
|
image->abstract_file_id = strdup(abstract_file_id);
|
||||||
@ -224,8 +224,7 @@ const char *iso_image_get_abstract_file_id(const IsoImage *image)
|
|||||||
return image->abstract_file_id;
|
return image->abstract_file_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void iso_image_set_biblio_file_id(IsoImage *image,
|
void iso_image_set_biblio_file_id(IsoImage *image, const char *biblio_file_id)
|
||||||
const char *biblio_file_id)
|
|
||||||
{
|
{
|
||||||
free(image->biblio_file_id);
|
free(image->biblio_file_id);
|
||||||
image->biblio_file_id = strdup(biblio_file_id);
|
image->biblio_file_id = strdup(biblio_file_id);
|
||||||
|
14
src/image.h
14
src/image.h
@ -24,7 +24,8 @@
|
|||||||
|
|
||||||
typedef struct Iso_Image_Rec_Opts IsoImageRecOpts;
|
typedef struct Iso_Image_Rec_Opts IsoImageRecOpts;
|
||||||
|
|
||||||
struct Iso_Image {
|
struct Iso_Image
|
||||||
|
{
|
||||||
|
|
||||||
int refcount;
|
int refcount;
|
||||||
|
|
||||||
@ -32,11 +33,11 @@ struct Iso_Image {
|
|||||||
|
|
||||||
char *volset_id;
|
char *volset_id;
|
||||||
|
|
||||||
char *volume_id; /**< Volume identifier. */
|
char *volume_id; /**< Volume identifier. */
|
||||||
char *publisher_id; /**< Volume publisher. */
|
char *publisher_id; /**< Volume publisher. */
|
||||||
char *data_preparer_id; /**< Volume data preparer. */
|
char *data_preparer_id; /**< Volume data preparer. */
|
||||||
char *system_id; /**< Volume system identifier. */
|
char *system_id; /**< Volume system identifier. */
|
||||||
char *application_id; /**< Volume application id */
|
char *application_id; /**< Volume application id */
|
||||||
char *copyright_file_id;
|
char *copyright_file_id;
|
||||||
char *abstract_file_id;
|
char *abstract_file_id;
|
||||||
char *biblio_file_id;
|
char *biblio_file_id;
|
||||||
@ -63,7 +64,8 @@ struct Iso_Image {
|
|||||||
/**
|
/**
|
||||||
* Options for recursive directory addition
|
* Options for recursive directory addition
|
||||||
*/
|
*/
|
||||||
struct Iso_Image_Rec_Opts {
|
struct Iso_Image_Rec_Opts
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether to follow symlinks or just add them as symlinks
|
* Whether to follow symlinks or just add them as symlinks
|
||||||
|
110
src/libisofs.h
110
src/libisofs.h
@ -58,28 +58,29 @@ enum IsoHideNodeFlag {
|
|||||||
/**
|
/**
|
||||||
* Holds the options for the image generation.
|
* Holds the options for the image generation.
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct
|
||||||
int level; /**< ISO level to write at. */
|
{
|
||||||
|
int level; /**< ISO level to write at. */
|
||||||
|
|
||||||
/** Which extensions to support. */
|
/** Which extensions to support. */
|
||||||
unsigned int rockridge:1;
|
unsigned int rockridge :1;
|
||||||
|
|
||||||
/* relaxed constraints */
|
/* relaxed constraints */
|
||||||
unsigned int omit_version_numbers:1;
|
unsigned int omit_version_numbers :1;
|
||||||
unsigned int allow_deep_paths:1;
|
unsigned int allow_deep_paths :1;
|
||||||
//int relaxed_constraints; /**< see ecma119_relaxed_constraints_flag */
|
//int relaxed_constraints; /**< see ecma119_relaxed_constraints_flag */
|
||||||
|
|
||||||
//unsigned int copy_eltorito:1;
|
//unsigned int copy_eltorito:1;
|
||||||
/**<
|
/**<
|
||||||
* In multisession discs, select whether to copy el-torito catalog
|
* In multisession discs, select whether to copy el-torito catalog
|
||||||
* and boot image. Copy is needed for isolinux images, that need to
|
* and boot image. Copy is needed for isolinux images, that need to
|
||||||
* be patched. However, it can lead to problems when the image is
|
* be patched. However, it can lead to problems when the image is
|
||||||
* not present in the iso filesystem, because we can't figure out
|
* not present in the iso filesystem, because we can't figure out
|
||||||
* its size. In those cases, we only copy 1 block of data.
|
* its size. In those cases, we only copy 1 block of data.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**< If files should be sorted based on their weight. */
|
/**< If files should be sorted based on their weight. */
|
||||||
unsigned int sort_files:1;
|
unsigned int sort_files :1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The following options set the default values for files and directory
|
* The following options set the default values for files and directory
|
||||||
@ -92,10 +93,10 @@ typedef struct {
|
|||||||
* below. Note that for mode attributes, only the permissions are set, the
|
* below. Note that for mode attributes, only the permissions are set, the
|
||||||
* file type remains unchanged.
|
* file type remains unchanged.
|
||||||
*/
|
*/
|
||||||
unsigned int replace_dir_mode:2;
|
unsigned int replace_dir_mode :2;
|
||||||
unsigned int replace_file_mode:2;
|
unsigned int replace_file_mode :2;
|
||||||
unsigned int replace_uid:2;
|
unsigned int replace_uid :2;
|
||||||
unsigned int replace_gid:2;
|
unsigned int replace_gid :2;
|
||||||
|
|
||||||
mode_t dir_mode; /** Mode to use on dirs when replace_dir_mode == 2. */
|
mode_t dir_mode; /** Mode to use on dirs when replace_dir_mode == 2. */
|
||||||
mode_t file_mode; /** Mode to use on files when replace_file_mode == 2. */
|
mode_t file_mode; /** Mode to use on files when replace_file_mode == 2. */
|
||||||
@ -103,35 +104,35 @@ typedef struct {
|
|||||||
gid_t gid; /** gid to use when replace_gid == 2. */
|
gid_t gid; /** gid to use when replace_gid == 2. */
|
||||||
|
|
||||||
char *output_charset; /**< NULL to use default charset */
|
char *output_charset; /**< NULL to use default charset */
|
||||||
// uint32_t ms_block;
|
// uint32_t ms_block;
|
||||||
/**<
|
/**<
|
||||||
* Start block for multisession. When this is greater than 0,
|
* Start block for multisession. When this is greater than 0,
|
||||||
* it's suppossed to be the lba of the next writable address
|
* it's suppossed to be the lba of the next writable address
|
||||||
* on disc; all block lba on image will take this into account,
|
* on disc; all block lba on image will take this into account,
|
||||||
* and files from a previous session will not be written on
|
* and files from a previous session will not be written on
|
||||||
* image. This behavior is only suitable for images to be
|
* image. This behavior is only suitable for images to be
|
||||||
* appended to a multisession disc.
|
* appended to a multisession disc.
|
||||||
* When this is 0, no multisession image will be created. If
|
* When this is 0, no multisession image will be created. If
|
||||||
* some files are taken from a previous image, its contents
|
* some files are taken from a previous image, its contents
|
||||||
* will be written again to the new image. Use this with new
|
* will be written again to the new image. Use this with new
|
||||||
* images or if you plan to modify an existin image.
|
* images or if you plan to modify an existin image.
|
||||||
*/
|
*/
|
||||||
// struct data_source* src;
|
// struct data_source* src;
|
||||||
// /**<
|
// /**<
|
||||||
// * When modifying a image, this is the source of the original
|
// * When modifying a image, this is the source of the original
|
||||||
// * image, used to read file contents.
|
// * image, used to read file contents.
|
||||||
// * Otherwise it can be NULL.
|
// * Otherwise it can be NULL.
|
||||||
// */
|
// */
|
||||||
// uint8_t *overwrite;
|
// uint8_t *overwrite;
|
||||||
// /**<
|
// /**<
|
||||||
// * When not NULL, it should point to a buffer of at least
|
// * When not NULL, it should point to a buffer of at least
|
||||||
// * 64KiB, where libisofs will write the contents that should
|
// * 64KiB, where libisofs will write the contents that should
|
||||||
// * be written at the beginning of a overwriteable media, to
|
// * be written at the beginning of a overwriteable media, to
|
||||||
// * grow the image.
|
// * grow the image.
|
||||||
// * You shoudl initialize the buffer either with 0s, or with
|
// * You shoudl initialize the buffer either with 0s, or with
|
||||||
// * the contents of the first blocks of the image you're
|
// * the contents of the first blocks of the image you're
|
||||||
// * growing. In most cases, 0 is good enought.
|
// * growing. In most cases, 0 is good enought.
|
||||||
// */
|
// */
|
||||||
} Ecma119WriteOpts;
|
} Ecma119WriteOpts;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -210,7 +211,7 @@ const char *iso_image_get_publisher_id(const IsoImage *image);
|
|||||||
* Fill in the data preparer for a image.
|
* Fill in the data preparer for a image.
|
||||||
*/
|
*/
|
||||||
void iso_image_set_data_preparer_id(IsoImage *image,
|
void iso_image_set_data_preparer_id(IsoImage *image,
|
||||||
const char *data_preparer_id);
|
const char *data_preparer_id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the data preparer of a image.
|
* Get the data preparer of a image.
|
||||||
@ -248,7 +249,7 @@ const char *iso_image_get_application_id(const IsoImage *image);
|
|||||||
* to a file on disc. Up to 37 characters.
|
* to a file on disc. Up to 37 characters.
|
||||||
*/
|
*/
|
||||||
void iso_image_set_copyright_file_id(IsoImage *image,
|
void iso_image_set_copyright_file_id(IsoImage *image,
|
||||||
const char *copyright_file_id);
|
const char *copyright_file_id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the copyright information of a image.
|
* Get the copyright information of a image.
|
||||||
@ -262,7 +263,7 @@ const char *iso_image_get_copyright_file_id(const IsoImage *image);
|
|||||||
* to a file on disc. Up to 37 characters.
|
* to a file on disc. Up to 37 characters.
|
||||||
*/
|
*/
|
||||||
void iso_image_set_abstract_file_id(IsoImage *image,
|
void iso_image_set_abstract_file_id(IsoImage *image,
|
||||||
const char *abstract_file_id);
|
const char *abstract_file_id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the abstract information of a image.
|
* Get the abstract information of a image.
|
||||||
@ -275,8 +276,7 @@ const char *iso_image_get_abstract_file_id(const IsoImage *image);
|
|||||||
* Fill biblio information for the image. Usually this refers
|
* Fill biblio information for the image. Usually this refers
|
||||||
* to a file on disc. Up to 37 characters.
|
* to a file on disc. Up to 37 characters.
|
||||||
*/
|
*/
|
||||||
void iso_image_set_biblio_file_id(IsoImage *image,
|
void iso_image_set_biblio_file_id(IsoImage *image, const char *biblio_file_id);
|
||||||
const char *biblio_file_id);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the biblio information of a image.
|
* Get the biblio information of a image.
|
||||||
@ -659,9 +659,9 @@ int iso_file_get_sort_weight(IsoFile *file);
|
|||||||
int iso_tree_add_new_dir(IsoDir *parent, const char *name, IsoDir **dir);
|
int iso_tree_add_new_dir(IsoDir *parent, const char *name, IsoDir **dir);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
TODO #00007 expose Strem and thi function:
|
TODO #00007 expose Strem and thi function:
|
||||||
int iso_tree_add_new_file(IsoDir *parent, const char *name, stream, file)
|
int iso_tree_add_new_file(IsoDir *parent, const char *name, stream, file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a new symlink to the directory tree. Permissions are set to 0777,
|
* Add a new symlink to the directory tree. Permissions are set to 0777,
|
||||||
@ -808,7 +808,7 @@ int iso_tree_path_to_node(IsoImage *image, const char *path, IsoNode **node);
|
|||||||
* @return >0 for success, <=0 for error
|
* @return >0 for success, <=0 for error
|
||||||
*/
|
*/
|
||||||
int iso_image_set_msgs_severities(IsoImage *img, char *queue_severity,
|
int iso_image_set_msgs_severities(IsoImage *img, char *queue_severity,
|
||||||
char *print_severity, char *print_id);
|
char *print_severity, char *print_id);
|
||||||
/**
|
/**
|
||||||
* Obtain the oldest pending message from a IsoImage message queue which has at
|
* Obtain the oldest pending message from a IsoImage message queue which has at
|
||||||
* least the given minimum_severity. This message and any older message of
|
* least the given minimum_severity. This message and any older message of
|
||||||
|
117
src/messages.c
117
src/messages.c
@ -25,13 +25,13 @@ void iso_msg_debug(IsoImage *img, const char *fmt, ...)
|
|||||||
vsnprintf(msg, MAX_MSG_LEN, fmt, ap);
|
vsnprintf(msg, MAX_MSG_LEN, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
libiso_msgs_submit(img->messenger, -1, 0x00000002, LIBISO_MSGS_SEV_DEBUG,
|
libiso_msgs_submit(img->messenger, -1, 0x00000002, LIBISO_MSGS_SEV_DEBUG,
|
||||||
LIBISO_MSGS_PRIO_ZERO, msg, 0, 0);
|
LIBISO_MSGS_PRIO_ZERO, msg, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void iso_msg_note(IsoImage *img, int error_code, const char *fmt, ...)
|
void iso_msg_note(IsoImage *img, int error_code, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
char msg[MAX_MSG_LEN];
|
char msg[MAX_MSG_LEN];
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
@ -44,7 +44,7 @@ void iso_msg_note(IsoImage *img, int error_code, const char *fmt, ...)
|
|||||||
|
|
||||||
void iso_msg_hint(IsoImage *img, int error_code, const char *fmt, ...)
|
void iso_msg_hint(IsoImage *img, int error_code, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
char msg[MAX_MSG_LEN];
|
char msg[MAX_MSG_LEN];
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
@ -57,44 +57,41 @@ void iso_msg_hint(IsoImage *img, int error_code, const char *fmt, ...)
|
|||||||
|
|
||||||
void iso_msg_warn(IsoImage *img, int error_code, const char *fmt, ...)
|
void iso_msg_warn(IsoImage *img, int error_code, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
char msg[MAX_MSG_LEN];
|
char msg[MAX_MSG_LEN];
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
vsnprintf(msg, MAX_MSG_LEN, fmt, ap);
|
vsnprintf(msg, MAX_MSG_LEN, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
libiso_msgs_submit(img->messenger, -1, error_code,
|
libiso_msgs_submit(img->messenger, -1, error_code, LIBISO_MSGS_SEV_WARNING,
|
||||||
LIBISO_MSGS_SEV_WARNING, LIBISO_MSGS_PRIO_MEDIUM,
|
LIBISO_MSGS_PRIO_MEDIUM, msg, 0, 0);
|
||||||
msg, 0, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void iso_msg_sorry(IsoImage *img, int error_code, const char *fmt, ...)
|
void iso_msg_sorry(IsoImage *img, int error_code, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
char msg[MAX_MSG_LEN];
|
char msg[MAX_MSG_LEN];
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
vsnprintf(msg, MAX_MSG_LEN, fmt, ap);
|
vsnprintf(msg, MAX_MSG_LEN, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
libiso_msgs_submit(img->messenger, -1, error_code,
|
libiso_msgs_submit(img->messenger, -1, error_code, LIBISO_MSGS_SEV_SORRY,
|
||||||
LIBISO_MSGS_SEV_SORRY, LIBISO_MSGS_PRIO_HIGH,
|
LIBISO_MSGS_PRIO_HIGH, msg, 0, 0);
|
||||||
msg, 0, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void iso_msg_fatal(IsoImage *img, int error_code, const char *fmt, ...)
|
void iso_msg_fatal(IsoImage *img, int error_code, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
char msg[MAX_MSG_LEN];
|
char msg[MAX_MSG_LEN];
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
vsnprintf(msg, MAX_MSG_LEN, fmt, ap);
|
vsnprintf(msg, MAX_MSG_LEN, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
libiso_msgs_submit(img->messenger, -1, error_code,
|
libiso_msgs_submit(img->messenger, -1, error_code, LIBISO_MSGS_SEV_FATAL,
|
||||||
LIBISO_MSGS_SEV_FATAL, LIBISO_MSGS_PRIO_HIGH,
|
LIBISO_MSGS_PRIO_HIGH, msg, 0, 0);
|
||||||
msg, 0, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -113,19 +110,19 @@ void iso_msg_fatal(IsoImage *img, int error_code, const char *fmt, ...)
|
|||||||
int iso_image_set_msgs_severities(IsoImage *img, char *queue_severity,
|
int iso_image_set_msgs_severities(IsoImage *img, char *queue_severity,
|
||||||
char *print_severity, char *print_id)
|
char *print_severity, char *print_id)
|
||||||
{
|
{
|
||||||
int ret, queue_sevno, print_sevno;
|
int ret, queue_sevno, print_sevno;
|
||||||
|
|
||||||
ret = libiso_msgs__text_to_sev(queue_severity, &queue_sevno, 0);
|
ret = libiso_msgs__text_to_sev(queue_severity, &queue_sevno, 0);
|
||||||
if (ret <= 0)
|
if (ret <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
ret = libiso_msgs__text_to_sev(print_severity, &print_sevno, 0);
|
ret = libiso_msgs__text_to_sev(print_severity, &print_sevno, 0);
|
||||||
if (ret <= 0)
|
if (ret <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
ret = libiso_msgs_set_severities(img->messenger, queue_sevno,
|
ret = libiso_msgs_set_severities(img->messenger, queue_sevno, print_sevno,
|
||||||
print_sevno, print_id, 0);
|
print_id, 0);
|
||||||
if (ret <= 0)
|
if (ret <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ISO_MSGS_MESSAGE_LEN 4096
|
#define ISO_MSGS_MESSAGE_LEN 4096
|
||||||
@ -147,47 +144,47 @@ int iso_image_set_msgs_severities(IsoImage *img, char *queue_severity,
|
|||||||
* @return 1 if a matching item was found, 0 if not, <0 for severe errors
|
* @return 1 if a matching item was found, 0 if not, <0 for severe errors
|
||||||
*/
|
*/
|
||||||
int iso_image_obtain_msgs(IsoImage *img, char *minimum_severity,
|
int iso_image_obtain_msgs(IsoImage *img, char *minimum_severity,
|
||||||
int *error_code, char msg_text[], int *os_errno,
|
int *error_code, char msg_text[], int *os_errno,
|
||||||
char severity[])
|
char severity[])
|
||||||
{
|
{
|
||||||
int ret, minimum_sevno, sevno, priority;
|
int ret, minimum_sevno, sevno, priority;
|
||||||
char *textpt, *sev_name;
|
char *textpt, *sev_name;
|
||||||
struct libiso_msgs_item *item = NULL;
|
struct libiso_msgs_item *item= NULL;
|
||||||
|
|
||||||
if (img == NULL)
|
if (img == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
ret = libiso_msgs__text_to_sev(minimum_severity, &minimum_sevno, 0);
|
ret = libiso_msgs__text_to_sev(minimum_severity, &minimum_sevno, 0);
|
||||||
if (ret <= 0)
|
if (ret <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
ret = libiso_msgs_obtain(img->messenger, &item, minimum_sevno,
|
ret = libiso_msgs_obtain(img->messenger, &item, minimum_sevno,
|
||||||
LIBISO_MSGS_PRIO_ZERO, 0);
|
LIBISO_MSGS_PRIO_ZERO, 0);
|
||||||
if (ret <= 0)
|
if (ret <= 0)
|
||||||
goto ex;
|
goto ex;
|
||||||
ret = libiso_msgs_item_get_msg(item, error_code, &textpt, os_errno, 0);
|
ret = libiso_msgs_item_get_msg(item, error_code, &textpt, os_errno, 0);
|
||||||
if (ret <= 0)
|
if (ret <= 0)
|
||||||
goto ex;
|
goto ex;
|
||||||
strncpy(msg_text, textpt, ISO_MSGS_MESSAGE_LEN-1);
|
strncpy(msg_text, textpt, ISO_MSGS_MESSAGE_LEN-1);
|
||||||
if(strlen(textpt) >= ISO_MSGS_MESSAGE_LEN)
|
if (strlen(textpt) >= ISO_MSGS_MESSAGE_LEN)
|
||||||
msg_text[ISO_MSGS_MESSAGE_LEN-1] = 0;
|
msg_text[ISO_MSGS_MESSAGE_LEN-1] = 0;
|
||||||
|
|
||||||
severity[0]= 0;
|
severity[0]= 0;
|
||||||
ret = libiso_msgs_item_get_rank(item, &sevno, &priority, 0);
|
ret = libiso_msgs_item_get_rank(item, &sevno, &priority, 0);
|
||||||
if(ret <= 0)
|
if (ret <= 0)
|
||||||
goto ex;
|
goto ex;
|
||||||
ret = libiso_msgs__sev_to_text(sevno, &sev_name, 0);
|
ret = libiso_msgs__sev_to_text(sevno, &sev_name, 0);
|
||||||
if(ret <= 0)
|
if (ret <= 0)
|
||||||
goto ex;
|
goto ex;
|
||||||
strcpy(severity,sev_name);
|
strcpy(severity, sev_name);
|
||||||
|
|
||||||
ret = 1;
|
ret = 1;
|
||||||
ex:
|
ex: ;
|
||||||
libiso_msgs_destroy_item(img->messenger, &item, 0);
|
libiso_msgs_destroy_item(img->messenger, &item, 0);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *iso_image_get_messenger(IsoImage *img)
|
void *iso_image_get_messenger(IsoImage *img)
|
||||||
{
|
{
|
||||||
return img->messenger;
|
return img->messenger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ void iso_node_ref(IsoNode *node)
|
|||||||
void iso_node_unref(IsoNode *node)
|
void iso_node_unref(IsoNode *node)
|
||||||
{
|
{
|
||||||
if (--node->refcount == 0) {
|
if (--node->refcount == 0) {
|
||||||
switch(node->type) {
|
switch (node->type) {
|
||||||
case LIBISO_DIR:
|
case LIBISO_DIR:
|
||||||
{
|
{
|
||||||
IsoNode *child = ((IsoDir*)node)->children;
|
IsoNode *child = ((IsoDir*)node)->children;
|
||||||
@ -168,7 +168,6 @@ mode_t iso_node_get_mode(const IsoNode *node)
|
|||||||
return node->mode;
|
return node->mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the user id for the node. This attribute is only useful when
|
* Set the user id for the node. This attribute is only useful when
|
||||||
* Rock Ridge extensions are enabled.
|
* Rock Ridge extensions are enabled.
|
||||||
@ -437,8 +436,7 @@ void iso_dir_iter_free(IsoDirIter *iter)
|
|||||||
free(iter);
|
free(iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
static IsoNode**
|
static IsoNode** iso_dir_find_node(IsoDir *dir, IsoNode *node)
|
||||||
iso_dir_find_node(IsoDir *dir, IsoNode *node)
|
|
||||||
{
|
{
|
||||||
IsoNode **pos;
|
IsoNode **pos;
|
||||||
pos = &(dir->children);
|
pos = &(dir->children);
|
||||||
|
14
src/node.h
14
src/node.h
@ -34,14 +34,14 @@ struct Iso_Node
|
|||||||
*/
|
*/
|
||||||
int refcount;
|
int refcount;
|
||||||
|
|
||||||
/**< Type of the IsoNode, do not confuse with mode */
|
/** Type of the IsoNode, do not confuse with mode */
|
||||||
enum IsoNodeType type;
|
enum IsoNodeType type;
|
||||||
|
|
||||||
char *name; /**< Real name, in default charset */
|
char *name; /**< Real name, in default charset */
|
||||||
|
|
||||||
mode_t mode; /**< protection */
|
mode_t mode; /**< protection */
|
||||||
uid_t uid; /**< user ID of owner */
|
uid_t uid; /**< user ID of owner */
|
||||||
gid_t gid; /**< group ID of owner */
|
gid_t gid; /**< group ID of owner */
|
||||||
|
|
||||||
/* TODO #00001 : consider adding new timestamps */
|
/* TODO #00001 : consider adding new timestamps */
|
||||||
time_t atime; /**< time of last access */
|
time_t atime; /**< time of last access */
|
||||||
@ -75,10 +75,10 @@ struct Iso_File
|
|||||||
*/
|
*/
|
||||||
uint32_t msblock;
|
uint32_t msblock;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* It sorts the order in which the file data is written to the CD image.
|
* It sorts the order in which the file data is written to the CD image.
|
||||||
* Higher weighting files are written at the beginning of image
|
* Higher weighting files are written at the beginning of image
|
||||||
*/
|
*/
|
||||||
int sort_weight;
|
int sort_weight;
|
||||||
IsoStream *stream;
|
IsoStream *stream;
|
||||||
};
|
};
|
||||||
|
@ -20,8 +20,8 @@ static
|
|||||||
int susp_append(Ecma119Image *t, struct susp_info *susp, uint8_t *data)
|
int susp_append(Ecma119Image *t, struct susp_info *susp, uint8_t *data)
|
||||||
{
|
{
|
||||||
susp->n_susp_fields++;
|
susp->n_susp_fields++;
|
||||||
susp->susp_fields = realloc(susp->susp_fields,
|
susp->susp_fields = realloc(susp->susp_fields, sizeof(void*)
|
||||||
sizeof(void*) * susp->n_susp_fields);
|
* susp->n_susp_fields);
|
||||||
if (susp->susp_fields == NULL) {
|
if (susp->susp_fields == NULL) {
|
||||||
return ISO_MEM_ERROR;
|
return ISO_MEM_ERROR;
|
||||||
}
|
}
|
||||||
@ -34,8 +34,8 @@ static
|
|||||||
int susp_append_ce(Ecma119Image *t, struct susp_info *susp, uint8_t *data)
|
int susp_append_ce(Ecma119Image *t, struct susp_info *susp, uint8_t *data)
|
||||||
{
|
{
|
||||||
susp->n_ce_susp_fields++;
|
susp->n_ce_susp_fields++;
|
||||||
susp->ce_susp_fields = realloc(susp->ce_susp_fields,
|
susp->ce_susp_fields = realloc(susp->ce_susp_fields, sizeof(void*)
|
||||||
sizeof(void*) * susp->n_ce_susp_fields);
|
* susp->n_ce_susp_fields);
|
||||||
if (susp->ce_susp_fields == NULL) {
|
if (susp->ce_susp_fields == NULL) {
|
||||||
return ISO_MEM_ERROR;
|
return ISO_MEM_ERROR;
|
||||||
}
|
}
|
||||||
@ -261,8 +261,8 @@ char *get_rr_name(Ecma119Image *t, Ecma119Node *n)
|
|||||||
ret = strconv(n->node->name, t->input_charset, t->output_charset, &name);
|
ret = strconv(n->node->name, t->input_charset, t->output_charset, &name);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
iso_msg_sorry(t->image, LIBISO_CHARSET_ERROR,
|
iso_msg_sorry(t->image, LIBISO_CHARSET_ERROR,
|
||||||
"Charset conversion error. Can't convert %s from %s to %s",
|
"Charset conversion error. Can't convert %s from %s to %s",
|
||||||
n->node->name, t->input_charset, t->output_charset);
|
n->node->name, t->input_charset, t->output_charset);
|
||||||
|
|
||||||
/* use the original name, it's the best we can do */
|
/* use the original name, it's the best we can do */
|
||||||
name = strdup(n->node->name);
|
name = strdup(n->node->name);
|
||||||
@ -285,8 +285,8 @@ char *get_rr_name(Ecma119Image *t, Ecma119Node *n)
|
|||||||
* Whether to add or not to CE
|
* Whether to add or not to CE
|
||||||
*/
|
*/
|
||||||
static
|
static
|
||||||
int rrip_add_NM(Ecma119Image *t, struct susp_info *susp,
|
int rrip_add_NM(Ecma119Image *t, struct susp_info *susp, char *name, int size,
|
||||||
char *name, int size, int flags, int ce)
|
int flags, int ce)
|
||||||
{
|
{
|
||||||
uint8_t *NM = malloc(size + 5);
|
uint8_t *NM = malloc(size + 5);
|
||||||
if (NM == NULL) {
|
if (NM == NULL) {
|
||||||
@ -325,8 +325,7 @@ int rrip_add_NM(Ecma119Image *t, struct susp_info *susp,
|
|||||||
* 1 on success, < 0 on error
|
* 1 on success, < 0 on error
|
||||||
*/
|
*/
|
||||||
static
|
static
|
||||||
int rrip_SL_append_comp(size_t *n, uint8_t ***comps,
|
int rrip_SL_append_comp(size_t *n, uint8_t ***comps, char *s, int size, char fl)
|
||||||
char *s, int size, char fl)
|
|
||||||
{
|
{
|
||||||
uint8_t *comp = malloc(size + 2);
|
uint8_t *comp = malloc(size + 2);
|
||||||
if (comp == NULL) {
|
if (comp == NULL) {
|
||||||
@ -363,8 +362,8 @@ int rrip_SL_append_comp(size_t *n, uint8_t ***comps,
|
|||||||
* Whether to add to a continuation area or system use field.
|
* Whether to add to a continuation area or system use field.
|
||||||
*/
|
*/
|
||||||
static
|
static
|
||||||
int rrip_add_SL(Ecma119Image *t, struct susp_info *susp,
|
int rrip_add_SL(Ecma119Image *t, struct susp_info *susp, uint8_t **comp,
|
||||||
uint8_t **comp, size_t n, int ce)
|
size_t n, int ce)
|
||||||
{
|
{
|
||||||
int ret, i, j;
|
int ret, i, j;
|
||||||
|
|
||||||
@ -388,7 +387,7 @@ int rrip_add_SL(Ecma119Image *t, struct susp_info *susp,
|
|||||||
SL[1] = 'L';
|
SL[1] = 'L';
|
||||||
SL[2] = total_comp_len + 5;
|
SL[2] = total_comp_len + 5;
|
||||||
SL[3] = 1;
|
SL[3] = 1;
|
||||||
SL[4] = 1; /* CONTINUE */
|
SL[4] = 1; /* CONTINUE */
|
||||||
pos = 5;
|
pos = 5;
|
||||||
for (j = written; j < i; j++) {
|
for (j = written; j < i; j++) {
|
||||||
memcpy(&SL[pos], comp[j], comp[j][1] + 2);
|
memcpy(&SL[pos], comp[j], comp[j][1] + 2);
|
||||||
@ -462,9 +461,9 @@ int rrip_add_ER(Ecma119Image *t, struct susp_info *susp)
|
|||||||
ER[7] = 1;
|
ER[7] = 1;
|
||||||
memcpy(&ER[8], "IEEE_1282", 9);
|
memcpy(&ER[8], "IEEE_1282", 9);
|
||||||
memcpy(&ER[17], "THE IEEE 1282 PROTOCOL PROVIDES SUPPORT FOR POSIX "
|
memcpy(&ER[17], "THE IEEE 1282 PROTOCOL PROVIDES SUPPORT FOR POSIX "
|
||||||
"FILE SYSTEM SEMANTICS.", 72);
|
"FILE SYSTEM SEMANTICS.", 72);
|
||||||
memcpy(&ER[89], "PLEASE CONTACT THE IEEE STANDARDS DEPARTMENT, "
|
memcpy(&ER[89], "PLEASE CONTACT THE IEEE STANDARDS DEPARTMENT, "
|
||||||
"PISCATAWAY, NJ, USA FOR THE 1282 SPECIFICATION.", 93);
|
"PISCATAWAY, NJ, USA FOR THE 1282 SPECIFICATION.", 93);
|
||||||
|
|
||||||
/** This always goes to continuation area */
|
/** This always goes to continuation area */
|
||||||
return susp_append_ce(t, susp, ER);
|
return susp_append_ce(t, susp, ER);
|
||||||
@ -531,8 +530,8 @@ int susp_add_SP(Ecma119Image *t, struct susp_info *susp)
|
|||||||
* @return
|
* @return
|
||||||
* The size needed for the RR entries in the System Use Area
|
* The size needed for the RR entries in the System Use Area
|
||||||
*/
|
*/
|
||||||
size_t rrip_calc_len(Ecma119Image *t, Ecma119Node *n, int type,
|
size_t rrip_calc_len(Ecma119Image *t, Ecma119Node *n, int type, size_t space,
|
||||||
size_t space, size_t *ce)
|
size_t *ce)
|
||||||
{
|
{
|
||||||
size_t su_size;
|
size_t su_size;
|
||||||
|
|
||||||
@ -754,7 +753,7 @@ int rrip_get_susp_fields(Ecma119Image *t, Ecma119Node *n, int type,
|
|||||||
int ret;
|
int ret;
|
||||||
size_t i;
|
size_t i;
|
||||||
Ecma119Node *node;
|
Ecma119Node *node;
|
||||||
char *name = NULL;
|
char *name= NULL;
|
||||||
|
|
||||||
if (t == NULL || n == NULL || info == NULL) {
|
if (t == NULL || n == NULL || info == NULL) {
|
||||||
return ISO_NULL_POINTER;
|
return ISO_NULL_POINTER;
|
||||||
@ -841,7 +840,7 @@ int rrip_get_susp_fields(Ecma119Image *t, Ecma119Node *n, int type,
|
|||||||
size_t namelen;
|
size_t namelen;
|
||||||
|
|
||||||
/* this two are only defined for symlinks */
|
/* this two are only defined for symlinks */
|
||||||
uint8_t **comps = NULL; /* components of the SL field */
|
uint8_t **comps= NULL; /* components of the SL field */
|
||||||
size_t n_comp = 0; /* number of components */
|
size_t n_comp = 0; /* number of components */
|
||||||
|
|
||||||
name = get_rr_name(t, n);
|
name = get_rr_name(t, n);
|
||||||
@ -884,7 +883,8 @@ int rrip_get_susp_fields(Ecma119Image *t, Ecma119Node *n, int type,
|
|||||||
if (clen == 0) {
|
if (clen == 0) {
|
||||||
/* this refers to the roor directory, '/' */
|
/* this refers to the roor directory, '/' */
|
||||||
cflag = 1 << 3;
|
cflag = 1 << 3;
|
||||||
} if (clen == 1 && prev[0] == '.') {
|
}
|
||||||
|
if (clen == 1 && prev[0] == '.') {
|
||||||
clen = 0;
|
clen = 0;
|
||||||
cflag = 1 << 1;
|
cflag = 1 << 1;
|
||||||
} else if (clen == 2 && prev[0] == '.' && prev[1] == '.') {
|
} else if (clen == 2 && prev[0] == '.' && prev[1] == '.') {
|
||||||
@ -952,10 +952,8 @@ int rrip_get_susp_fields(Ecma119Image *t, Ecma119Node *n, int type,
|
|||||||
* and another component, that will go in
|
* and another component, that will go in
|
||||||
* other SL entry
|
* other SL entry
|
||||||
*/
|
*/
|
||||||
ret = rrip_SL_append_comp(&n_comp, &comps,
|
ret = rrip_SL_append_comp(&n_comp, &comps, prev
|
||||||
prev + fit,
|
+ fit, clen - fit - 2, 0);
|
||||||
clen - fit - 2,
|
|
||||||
0);
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
goto add_susp_cleanup;
|
goto add_susp_cleanup;
|
||||||
}
|
}
|
||||||
@ -972,10 +970,8 @@ int rrip_get_susp_fields(Ecma119Image *t, Ecma119Node *n, int type,
|
|||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
goto add_susp_cleanup;
|
goto add_susp_cleanup;
|
||||||
}
|
}
|
||||||
ret = rrip_SL_append_comp(&n_comp, &comps,
|
ret = rrip_SL_append_comp(&n_comp, &comps, prev
|
||||||
prev + 248,
|
+ 248, strlen(prev + 248), 0x00);
|
||||||
strlen(prev + 248),
|
|
||||||
0x00);
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
goto add_susp_cleanup;
|
goto add_susp_cleanup;
|
||||||
}
|
}
|
||||||
@ -1076,7 +1072,6 @@ int rrip_get_susp_fields(Ecma119Image *t, Ecma119Node *n, int type,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
/* "." or ".." entry */
|
/* "." or ".." entry */
|
||||||
@ -1113,7 +1108,7 @@ int rrip_get_susp_fields(Ecma119Image *t, Ecma119Node *n, int type,
|
|||||||
free(name);
|
free(name);
|
||||||
return ISO_SUCCESS;
|
return ISO_SUCCESS;
|
||||||
|
|
||||||
add_susp_cleanup:;
|
add_susp_cleanup: ;
|
||||||
free(name);
|
free(name);
|
||||||
susp_info_free(info);
|
susp_info_free(info);
|
||||||
return ret;
|
return ret;
|
||||||
@ -1160,7 +1155,7 @@ int rrip_write_ce_fields(Ecma119Image *t, struct susp_info *info)
|
|||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
uint8_t padding[BLOCK_SIZE];
|
uint8_t padding[BLOCK_SIZE];
|
||||||
int ret = ISO_SUCCESS;
|
int ret= ISO_SUCCESS;
|
||||||
|
|
||||||
if (info->n_ce_susp_fields == 0) {
|
if (info->n_ce_susp_fields == 0) {
|
||||||
return ret;
|
return ret;
|
||||||
@ -1181,7 +1176,7 @@ int rrip_write_ce_fields(Ecma119Image *t, struct susp_info *info)
|
|||||||
ret = iso_write(t, padding, i);
|
ret = iso_write(t, padding, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
write_ce_field_cleanup:;
|
write_ce_field_cleanup: ;
|
||||||
/* free ce_susp_fields */
|
/* free ce_susp_fields */
|
||||||
for (i = 0; i < info->n_ce_susp_fields; ++i) {
|
for (i = 0; i < info->n_ce_susp_fields; ++i) {
|
||||||
free(info->ce_susp_fields[i]);
|
free(info->ce_susp_fields[i]);
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
|
|
||||||
#include "ecma119.h"
|
#include "ecma119.h"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This contains the information about the System Use Fields (SUSP, 4.1),
|
* This contains the information about the System Use Fields (SUSP, 4.1),
|
||||||
* that will be written in the System Use Areas, both in the ISO directory
|
* that will be written in the System Use Areas, both in the ISO directory
|
||||||
@ -66,8 +65,8 @@ struct susp_info
|
|||||||
* @return
|
* @return
|
||||||
* The size needed for the RR entries in the System Use Area
|
* The size needed for the RR entries in the System Use Area
|
||||||
*/
|
*/
|
||||||
size_t rrip_calc_len(Ecma119Image *t, Ecma119Node *n, int type,
|
size_t rrip_calc_len(Ecma119Image *t, Ecma119Node *n, int type, size_t space,
|
||||||
size_t space, size_t *ce);
|
size_t *ce);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fill a struct susp_info with the RR/SUSP entries needed for a given
|
* Fill a struct susp_info with the RR/SUSP entries needed for a given
|
||||||
|
20
src/stream.h
20
src/stream.h
@ -98,33 +98,39 @@ void iso_stream_ref(IsoStream *stream);
|
|||||||
void iso_stream_unref(IsoStream *stream);
|
void iso_stream_unref(IsoStream *stream);
|
||||||
|
|
||||||
extern inline
|
extern inline
|
||||||
int iso_stream_open(IsoStream *stream) {
|
int iso_stream_open(IsoStream *stream)
|
||||||
|
{
|
||||||
return stream->class->open(stream);
|
return stream->class->open(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern inline
|
extern inline
|
||||||
int iso_stream_close(IsoStream *stream) {
|
int iso_stream_close(IsoStream *stream)
|
||||||
|
{
|
||||||
return stream->class->close(stream);
|
return stream->class->close(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern inline
|
extern inline
|
||||||
off_t iso_stream_get_size(IsoStream *stream) {
|
off_t iso_stream_get_size(IsoStream *stream)
|
||||||
|
{
|
||||||
return stream->class->get_size(stream);
|
return stream->class->get_size(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern inline
|
extern inline
|
||||||
int iso_stream_read(IsoStream *stream, void *buf, size_t count) {
|
int iso_stream_read(IsoStream *stream, void *buf, size_t count)
|
||||||
|
{
|
||||||
return stream->class->read(stream, buf, count);
|
return stream->class->read(stream, buf, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern inline
|
extern inline
|
||||||
int iso_stream_is_repeatable(IsoStream *stream) {
|
int iso_stream_is_repeatable(IsoStream *stream)
|
||||||
|
{
|
||||||
return stream->class->is_repeatable(stream);
|
return stream->class->is_repeatable(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern inline
|
extern inline
|
||||||
int iso_stream_get_id(IsoStream *stream, unsigned int *fs_id,
|
int iso_stream_get_id(IsoStream *stream, unsigned int *fs_id, dev_t *dev_id,
|
||||||
dev_t *dev_id, ino_t *ino_id) {
|
ino_t *ino_id)
|
||||||
|
{
|
||||||
return stream->class->get_id(stream, fs_id, dev_id, ino_id);
|
return stream->class->get_id(stream, fs_id, dev_id, ino_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -458,8 +458,8 @@ int iso_add_dir_aux(IsoImage *image, IsoDir *parent, IsoFileSource *dir)
|
|||||||
result = builder->create_node(builder, image, file, &new);
|
result = builder->create_node(builder, image, file, &new);
|
||||||
if (result < 0) {
|
if (result < 0) {
|
||||||
|
|
||||||
iso_msg_debug(image, "Error %d when adding file %s",
|
iso_msg_debug(image, "Error %d when adding file %s", result,
|
||||||
result, iso_file_source_get_path(file));
|
iso_file_source_get_path(file));
|
||||||
|
|
||||||
if (image->recOpts->report) {
|
if (image->recOpts->report) {
|
||||||
action = image->recOpts->report(file, result, flag);
|
action = image->recOpts->report(file, result, flag);
|
||||||
|
123
src/util.c
123
src/util.c
@ -28,7 +28,6 @@ int int_pow(int base, int power)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int strconv(const char *str, const char *icharset, const char *ocharset,
|
int strconv(const char *str, const char *icharset, const char *ocharset,
|
||||||
char **output)
|
char **output)
|
||||||
{
|
{
|
||||||
@ -190,7 +189,7 @@ int str2ascii(const char *icharset, const char *input, char **output)
|
|||||||
}
|
}
|
||||||
|
|
||||||
n = iconv(conv, &src, &inbytes, &ret, &outbytes);
|
n = iconv(conv, &src, &inbytes, &ret, &outbytes);
|
||||||
while(n == -1) {
|
while (n == -1) {
|
||||||
/* The destination buffer is too small. Stops here. */
|
/* The destination buffer is too small. Stops here. */
|
||||||
if (errno == E2BIG)
|
if (errno == E2BIG)
|
||||||
break;
|
break;
|
||||||
@ -238,8 +237,8 @@ static int valid_d_char(char c)
|
|||||||
|
|
||||||
static int valid_a_char(char c)
|
static int valid_a_char(char c)
|
||||||
{
|
{
|
||||||
return (c >= ' ' && c <= '"') || (c >= '%' && c <= '?')
|
return (c >= ' ' && c <= '"') || (c >= '%' && c <= '?') ||
|
||||||
|| (c >= 'A' && c <= 'Z') || (c == '_');
|
(c >= 'A' && c <= 'Z') || (c == '_');
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
@ -253,7 +252,7 @@ char *iso_dirid(const char *src, int size)
|
|||||||
len = size;
|
len = size;
|
||||||
}
|
}
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
char c = toupper(src[i]);
|
char c= toupper(src[i]);
|
||||||
name[i] = valid_d_char(c) ? c : '_';
|
name[i] = valid_d_char(c) ? c : '_';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -274,7 +273,7 @@ char *iso_2_dirid(const char *src)
|
|||||||
char *iso_1_fileid(const char *src)
|
char *iso_1_fileid(const char *src)
|
||||||
{
|
{
|
||||||
char *dot; /* Position of the last dot in the filename, will be used
|
char *dot; /* Position of the last dot in the filename, will be used
|
||||||
to calculate lname and lext. */
|
* to calculate lname and lext. */
|
||||||
int lname, lext, pos, i;
|
int lname, lext, pos, i;
|
||||||
char dest[13]; /* 13 = 8 (name) + 1 (.) + 3 (ext) + 1 (\0) */
|
char dest[13]; /* 13 = 8 (name) + 1 (.) + 3 (ext) + 1 (\0) */
|
||||||
|
|
||||||
@ -295,7 +294,7 @@ char *iso_1_fileid(const char *src)
|
|||||||
|
|
||||||
/* Convert up to 8 characters of the filename. */
|
/* Convert up to 8 characters of the filename. */
|
||||||
for (i = 0; i < lname && i < 8; i++) {
|
for (i = 0; i < lname && i < 8; i++) {
|
||||||
char c = toupper(src[i]);
|
char c= toupper(src[i]);
|
||||||
|
|
||||||
dest[pos++] = valid_d_char(c) ? c : '_';
|
dest[pos++] = valid_d_char(c) ? c : '_';
|
||||||
}
|
}
|
||||||
@ -305,7 +304,7 @@ char *iso_1_fileid(const char *src)
|
|||||||
|
|
||||||
/* Convert up to 3 characters of the extension, if any. */
|
/* Convert up to 3 characters of the extension, if any. */
|
||||||
for (i = 0; i < lext && i < 3; i++) {
|
for (i = 0; i < lext && i < 3; i++) {
|
||||||
char c = toupper(src[lname + 1 + i]);
|
char c= toupper(src[lname + 1 + i]);
|
||||||
|
|
||||||
dest[pos++] = valid_d_char(c) ? c : '_';
|
dest[pos++] = valid_d_char(c) ? c : '_';
|
||||||
}
|
}
|
||||||
@ -339,8 +338,8 @@ char *iso_2_fileid(const char *src)
|
|||||||
} else {
|
} else {
|
||||||
lext = strlen(dot + 1);
|
lext = strlen(dot + 1);
|
||||||
lname = strlen(src) - lext - 1;
|
lname = strlen(src) - lext - 1;
|
||||||
lnext = (strlen(src) > 31 && lext > 3)
|
lnext = (strlen(src) > 31 && lext > 3) ? (lname < 27 ? 30 - lname : 3)
|
||||||
? (lname < 27 ? 30 - lname : 3) : lext;
|
: lext;
|
||||||
lnname = (strlen(src) > 31) ? 30 - lnext : lname;
|
lnname = (strlen(src) > 31) ? 30 - lnext : lname;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -352,7 +351,7 @@ char *iso_2_fileid(const char *src)
|
|||||||
|
|
||||||
/* Convert up to lnname characters of the filename. */
|
/* Convert up to lnname characters of the filename. */
|
||||||
for (i = 0; i < lnname; i++) {
|
for (i = 0; i < lnname; i++) {
|
||||||
char c = toupper(src[i]);
|
char c= toupper(src[i]);
|
||||||
|
|
||||||
dest[pos++] = valid_d_char(c) ? c : '_';
|
dest[pos++] = valid_d_char(c) ? c : '_';
|
||||||
}
|
}
|
||||||
@ -360,7 +359,7 @@ char *iso_2_fileid(const char *src)
|
|||||||
|
|
||||||
/* Convert up to lnext characters of the extension, if any. */
|
/* Convert up to lnext characters of the extension, if any. */
|
||||||
for (i = 0; i < lnext; i++) {
|
for (i = 0; i < lnext; i++) {
|
||||||
char c = toupper(src[lname + 1 + i]);
|
char c= toupper(src[lname + 1 + i]);
|
||||||
|
|
||||||
dest[pos++] = valid_d_char(c) ? c : '_';
|
dest[pos++] = valid_d_char(c) ? c : '_';
|
||||||
}
|
}
|
||||||
@ -368,102 +367,6 @@ char *iso_2_fileid(const char *src)
|
|||||||
return strdup(dest);
|
return strdup(dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
//void iso_dirid(char *src, int maxlen)
|
|
||||||
//{
|
|
||||||
// size_t len, i;
|
|
||||||
//
|
|
||||||
// len = strlen(src);
|
|
||||||
// if (len > maxlen) {
|
|
||||||
// src[maxlen] = '\0';
|
|
||||||
// len = maxlen;
|
|
||||||
// }
|
|
||||||
// for (i = 0; i < len; i++) {
|
|
||||||
// char c = toupper(src[i]);
|
|
||||||
// src[i] = valid_d_char(c) ? c : '_';
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
//void iso_1_fileid(char *src)
|
|
||||||
//{
|
|
||||||
// char *dot; /* Position of the last dot in the filename, will be used to
|
|
||||||
// calculate lname and lext. */
|
|
||||||
// int lname, lext, pos, i;
|
|
||||||
//
|
|
||||||
// dot = strrchr(src, '.');
|
|
||||||
//
|
|
||||||
// lext = dot ? strlen(dot + 1) : 0;
|
|
||||||
// lname = strlen(src) - lext - (dot ? 1 : 0);
|
|
||||||
//
|
|
||||||
// /* If we can't build a filename, return. */
|
|
||||||
// if (lname == 0 && lext == 0) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// pos = 0;
|
|
||||||
// /* Convert up to 8 characters of the filename. */
|
|
||||||
// for (i = 0; i < lname && i < 8; i++) {
|
|
||||||
// char c = toupper(src[i]);
|
|
||||||
// src[pos++] = valid_d_char(c) ? c : '_';
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /* This dot is mandatory, even if there is no extension. */
|
|
||||||
// src[pos++] = '.';
|
|
||||||
//
|
|
||||||
// /* Convert up to 3 characters of the extension, if any. */
|
|
||||||
// for (i = 0; i < lext && i < 3; i++) {
|
|
||||||
// char c = toupper(src[lname + 1 + i]);
|
|
||||||
// src[pos++] = valid_d_char(c) ? c : '_';
|
|
||||||
// }
|
|
||||||
// src[pos] = '\0';
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//void iso_2_fileid(char *src)
|
|
||||||
//{
|
|
||||||
// char *dot;
|
|
||||||
// int lname, lext, lnname, lnext, pos, i;
|
|
||||||
//
|
|
||||||
// if (!src)
|
|
||||||
// return;
|
|
||||||
//
|
|
||||||
// dot = strrchr(src, '.');
|
|
||||||
//
|
|
||||||
// /*
|
|
||||||
// * Since the maximum length can be divided freely over the name and
|
|
||||||
// * extension, we need to calculate their new lengths (lnname and
|
|
||||||
// * lnext). If the original filename is too long, we start by trimming
|
|
||||||
// * the extension, but keep a minimum extension length of 3.
|
|
||||||
// */
|
|
||||||
// if (dot == NULL || *(dot + 1) == '\0') {
|
|
||||||
// lname = strlen(src);
|
|
||||||
// lnname = (lname > 30) ? 30 : lname;
|
|
||||||
// lext = lnext = 0;
|
|
||||||
// } else {
|
|
||||||
// lext = strlen(dot + 1);
|
|
||||||
// lname = strlen(src) - lext - 1;
|
|
||||||
// lnext = (strlen(src) > 31 && lext > 3)
|
|
||||||
// ? (lname < 27 ? 30 - lname : 3) : lext;
|
|
||||||
// lnname = (strlen(src) > 31) ? 30 - lnext : lname;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (lnname == 0 && lnext == 0) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// pos = 0;
|
|
||||||
// /* Convert up to lnname characters of the filename. */
|
|
||||||
// for (i = 0; i < lnname; i++) {
|
|
||||||
// char c = toupper(src[i]);
|
|
||||||
// src[pos++] = valid_d_char(c) ? c : '_';
|
|
||||||
// }
|
|
||||||
// src[pos++] = '.';
|
|
||||||
// /* Convert up to lnext characters of the extension, if any. */
|
|
||||||
// for (i = 0; i < lnext; i++) {
|
|
||||||
// char c = toupper(src[lname + 1 + i]);
|
|
||||||
// src[pos++] = valid_d_char(c) ? c : '_';
|
|
||||||
// }
|
|
||||||
// src[pos] = '\0';
|
|
||||||
//}
|
|
||||||
|
|
||||||
int str2d_char(const char *icharset, const char *input, char **output)
|
int str2d_char(const char *icharset, const char *input, char **output)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
@ -490,7 +393,7 @@ int str2d_char(const char *icharset, const char *input, char **output)
|
|||||||
len = strlen(ascii);
|
len = strlen(ascii);
|
||||||
|
|
||||||
for (i = 0; i < len; ++i) {
|
for (i = 0; i < len; ++i) {
|
||||||
char c = toupper(ascii[i]);
|
char c= toupper(ascii[i]);
|
||||||
ascii[i] = valid_d_char(c) ? c : '_';
|
ascii[i] = valid_d_char(c) ? c : '_';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -524,7 +427,7 @@ int str2a_char(const char *icharset, const char *input, char **output)
|
|||||||
len = strlen(ascii);
|
len = strlen(ascii);
|
||||||
|
|
||||||
for (i = 0; i < len; ++i) {
|
for (i = 0; i < len; ++i) {
|
||||||
char c = toupper(ascii[i]);
|
char c= toupper(ascii[i]);
|
||||||
ascii[i] = valid_a_char(c) ? c : '_';
|
ascii[i] = valid_a_char(c) ? c : '_';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,13 +16,15 @@
|
|||||||
* implementation of Julienne Walker.
|
* implementation of Julienne Walker.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct iso_rbnode {
|
struct iso_rbnode
|
||||||
|
{
|
||||||
void *data;
|
void *data;
|
||||||
struct iso_rbnode *ch[2];
|
struct iso_rbnode *ch[2];
|
||||||
unsigned int red:1;
|
unsigned int red :1;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct iso_rbtree {
|
struct iso_rbtree
|
||||||
|
{
|
||||||
struct iso_rbnode *root;
|
struct iso_rbnode *root;
|
||||||
size_t size;
|
size_t size;
|
||||||
int (*compare)(const void *a, const void *b);
|
int (*compare)(const void *a, const void *b);
|
||||||
@ -40,8 +42,7 @@ struct iso_rbtree {
|
|||||||
* @param tree
|
* @param tree
|
||||||
* Location where the tree structure will be stored.
|
* Location where the tree structure will be stored.
|
||||||
*/
|
*/
|
||||||
int
|
int iso_rbtree_new(int (*compare)(const void*, const void*), IsoRBTree **tree)
|
||||||
iso_rbtree_new(int (*compare)(const void*, const void*), IsoRBTree **tree)
|
|
||||||
{
|
{
|
||||||
if (compare == NULL || tree == NULL) {
|
if (compare == NULL || tree == NULL) {
|
||||||
return ISO_NULL_POINTER;
|
return ISO_NULL_POINTER;
|
||||||
@ -75,8 +76,7 @@ void rbtree_destroy_aux(struct iso_rbnode *root, void (*free_data)(void *))
|
|||||||
* should provide a valid free_data function. It will be called for each
|
* should provide a valid free_data function. It will be called for each
|
||||||
* element of the tree, so you can use it to free any related data.
|
* element of the tree, so you can use it to free any related data.
|
||||||
*/
|
*/
|
||||||
void
|
void iso_rbtree_destroy(IsoRBTree *tree, void (*free_data)(void *))
|
||||||
iso_rbtree_destroy(IsoRBTree *tree, void (*free_data)(void *))
|
|
||||||
{
|
{
|
||||||
if (tree == NULL) {
|
if (tree == NULL) {
|
||||||
return;
|
return;
|
||||||
@ -116,7 +116,7 @@ struct iso_rbnode *iso_rbnode_new(void *data)
|
|||||||
{
|
{
|
||||||
struct iso_rbnode *rn = malloc(sizeof(struct iso_rbnode));
|
struct iso_rbnode *rn = malloc(sizeof(struct iso_rbnode));
|
||||||
|
|
||||||
if ( rn != NULL ) {
|
if (rn != NULL) {
|
||||||
rn->data = data;
|
rn->data = data;
|
||||||
rn->red = 1;
|
rn->red = 1;
|
||||||
rn->ch[0] = NULL;
|
rn->ch[0] = NULL;
|
||||||
@ -154,15 +154,15 @@ int iso_rbtree_insert(IsoRBTree *tree, void *data, void **item)
|
|||||||
/* Empty tree case */
|
/* Empty tree case */
|
||||||
tree->root = iso_rbnode_new(data);
|
tree->root = iso_rbnode_new(data);
|
||||||
if (tree->root == NULL) {
|
if (tree->root == NULL) {
|
||||||
return ISO_MEM_ERROR;
|
return ISO_MEM_ERROR;
|
||||||
}
|
}
|
||||||
new = data;
|
new = data;
|
||||||
added = 1;
|
added = 1;
|
||||||
} else {
|
} else {
|
||||||
struct iso_rbnode head = {0}; /* False tree root */
|
struct iso_rbnode head = { 0 }; /* False tree root */
|
||||||
|
|
||||||
struct iso_rbnode *g, *t; /* Grandparent & parent */
|
struct iso_rbnode *g, *t; /* Grandparent & parent */
|
||||||
struct iso_rbnode *p, *q; /* Iterator & parent */
|
struct iso_rbnode *p, *q; /* Iterator & parent */
|
||||||
int dir = 0, last = 0;
|
int dir = 0, last = 0;
|
||||||
int comp;
|
int comp;
|
||||||
|
|
||||||
@ -243,7 +243,6 @@ size_t iso_rbtree_get_size(IsoRBTree *tree)
|
|||||||
return tree->size;
|
return tree->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static
|
static
|
||||||
int rbtree_to_array_aux(struct iso_rbnode *root, void **array, size_t pos)
|
int rbtree_to_array_aux(struct iso_rbnode *root, void **array, size_t pos)
|
||||||
{
|
{
|
||||||
@ -265,8 +264,7 @@ int rbtree_to_array_aux(struct iso_rbnode *root, void **array, size_t pos)
|
|||||||
* no more needed. Note that the array is NULL-terminated, and thus it
|
* no more needed. Note that the array is NULL-terminated, and thus it
|
||||||
* has size + 1 length.
|
* has size + 1 length.
|
||||||
*/
|
*/
|
||||||
void **
|
void ** iso_rbtree_to_array(IsoRBTree *tree)
|
||||||
iso_rbtree_to_array(IsoRBTree *tree)
|
|
||||||
{
|
{
|
||||||
void **array;
|
void **array;
|
||||||
|
|
||||||
|
@ -28,8 +28,7 @@ struct Iso_Image_Writer
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the function all Writers shoudl call to write data to
|
* This is the function all Writers shoudl call to write data to image.
|
||||||
* image.
|
|
||||||
* Currently, it is just a wrapper for write(2) Unix system call.
|
* Currently, it is just a wrapper for write(2) Unix system call.
|
||||||
*
|
*
|
||||||
* It is implemented in ecma119.c
|
* It is implemented in ecma119.c
|
||||||
|
Loading…
x
Reference in New Issue
Block a user