Define code style formatter for eclipse and apply it to source.

This commit is contained in:
Vreixo Formoso 2007-12-28 22:10:17 +01:00
parent 1ecb735e7c
commit 4c9d83f051
31 changed files with 1018 additions and 1019 deletions

View File

@ -313,6 +313,7 @@
</profile>
</scannerConfigBuildInfo>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.language.mapping"/>
</cconfiguration>
<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">
@ -624,6 +625,7 @@
</profile>
</scannerConfigBuildInfo>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.language.mapping"/>
</cconfiguration>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">

View File

@ -1,4 +1,4 @@
#Fri Dec 28 17:36:33 CET 2007
#Fri Dec 28 21:07:56 CET 2007
eclipse.preferences.version=1
indexer/filesToParseUpFront=
indexer/indexAllFiles=true

View File

@ -22,7 +22,8 @@
* the libisofs ring buffer as intermediate memory
*/
struct th_data {
struct th_data
{
IsoRingBuffer *rbuf;
char *path;
};
@ -46,19 +47,19 @@ void *write_function(void *arg)
}
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);
if (res <= 0) {
break;
}
/* To test premature reader exit >>>>>>>>>>>
iso_ring_buffer_writer_close(data->rbuf);
pthread_exit(NULL);
<<<<<<<<<<<<<<<<<<<<<<<<< */
// if (rand() > 2000000000) {
// fprintf(stderr, "Writer sleeping\n");
// sleep(1);
// }
iso_ring_buffer_writer_close(data->rbuf);
pthread_exit(NULL);
<<<<<<<<<<<<<<<<<<<<<<<<< */
// if (rand() > 2000000000) {
// fprintf(stderr, "Writer sleeping\n");
// sleep(1);
// }
}
fprintf(stderr, "Writer finish: %d\n", res);
@ -74,16 +75,16 @@ void *read_function(void *arg)
int res = 1;
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);
/* To test premature reader exit >>>>>>>>>>>
iso_ring_buffer_reader_close(data->rbuf);
pthread_exit(NULL);
<<<<<<<<<<<<<<<<<<<<<<<<< */
// if (rand() > 2000000000) {
// fprintf(stderr, "Reader sleeping\n");
// sleep(1);
// }
iso_ring_buffer_reader_close(data->rbuf);
pthread_exit(NULL);
<<<<<<<<<<<<<<<<<<<<<<<<< */
// if (rand() > 2000000000) {
// fprintf(stderr, "Reader sleeping\n");
// sleep(1);
// }
}
fprintf(stderr, "Reader finish: %d\n", res);
@ -118,8 +119,8 @@ int main(int argc, char **argv)
pthread_join(reader, NULL);
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_empty(data.rbuf));
iso_ring_buffer_get_times_full(data.rbuf),
iso_ring_buffer_get_times_empty(data.rbuf));
free(data.rbuf);
return 0;

91
doc/devel/codestyle.xml Normal file
View 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>

View File

@ -28,7 +28,8 @@
# define MIN(a, b) (((a) < (b)) ? (a) : (b))
#endif
struct iso_ring_buffer {
struct iso_ring_buffer
{
uint8_t buf[BLOCK_SIZE * BUFFER_SIZE];
/*
@ -41,8 +42,8 @@ struct iso_ring_buffer {
size_t wpos;
/* flags to report if read or writer threads ends execution */
unsigned int rend:1;
unsigned int wend:1;
unsigned int rend :1;
unsigned int wend :1;
/* just for statistical purposes */
unsigned int times_full;

View File

@ -73,7 +73,8 @@ size_t calc_dirent_len(Ecma119Image *t, Ecma119Node *n)
if (need_version_number(t, n)) {
ret += 2; /* take into account version numbers */
}
if (ret % 2) ret++;
if (ret % 2)
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];
size_t dirent_len = calc_dirent_len(t, child);
if (t->rockridge) {
dirent_len += rrip_calc_len(t, child, 0, 255 - dirent_len,
&ce_len);
dirent_len += rrip_calc_len(t, child, 0, 255 - dirent_len, &ce_len);
*ce += ce_len;
}
remaining = BLOCK_SIZE - (len % BLOCK_SIZE);
@ -218,13 +218,13 @@ int ecma119_writer_compute_data_blocks(IsoImageWriter *writer)
*/
static
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 block;
uint8_t len_dr; /*< size of dir entry without SUSP fields */
uint8_t *name = (file_id >= 0) ? (uint8_t*)&file_id :
(uint8_t*)node->iso_name;
uint8_t *name = (file_id >= 0) ? (uint8_t*)&file_id
: (uint8_t*)node->iso_name;
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;
}
if ( (buf + len - buffer) > BLOCK_SIZE ) {
if ( (buf + len - buffer) > BLOCK_SIZE) {
/* dir doesn't fit in current block */
ret = iso_write(t, buffer, BLOCK_SIZE);
if (ret < 0) {
@ -496,7 +496,7 @@ int write_path_table(Ecma119Image *t, Ecma119Node **pathlist, int l_type)
Ecma119Node *dir;
uint32_t path_table_size;
int parent = 0;
int ret = ISO_SUCCESS;
int ret= ISO_SUCCESS;
path_table_size = 0;
write_int = l_type ? iso_lsb : iso_msb;
@ -575,7 +575,7 @@ int write_path_tables(Ecma119Image *t)
/* Write L Path Table */
ret = write_path_table(t, pathlist, 0);
write_path_tables_exit:;
write_path_tables_exit: ;
free(pathlist);
return ret;
}
@ -702,7 +702,7 @@ void *write_function(void *arg)
iso_ring_buffer_writer_close(target->buffer);
pthread_exit(NULL);
write_error:;
write_error: ;
iso_msg_fatal(target->image, LIBISO_WRITE_ERROR,
"Image write error, code %d", res);
iso_ring_buffer_writer_close(target->buffer);
@ -710,8 +710,7 @@ write_error:;
}
static
int ecma119_image_new(IsoImage *src, Ecma119WriteOpts *opts,
Ecma119Image **img)
int ecma119_image_new(IsoImage *src, Ecma119WriteOpts *opts, Ecma119Image **img)
{
int ret, i;
Ecma119Image *target;
@ -857,13 +856,12 @@ int ecma119_image_new(IsoImage *src, Ecma119WriteOpts *opts,
*img = target;
return ISO_SUCCESS;
target_cleanup:;
target_cleanup: ;
ecma119_image_free(target);
return ret;
}
static int
bs_read(struct burn_source *bs, unsigned char *buf, int size)
static int bs_read(struct burn_source *bs, unsigned char *buf, int size)
{
int ret;
Ecma119Image *t = (Ecma119Image*)bs->data;
@ -881,15 +879,13 @@ bs_read(struct burn_source *bs, unsigned char *buf, int size)
}
}
static off_t
bs_get_size(struct burn_source *bs)
static off_t bs_get_size(struct burn_source *bs)
{
Ecma119Image *target = (Ecma119Image*)bs->data;
return target->total_size;
}
static void
bs_free_data(struct burn_source *bs)
static void bs_free_data(struct burn_source *bs)
{
Ecma119Image *target = (Ecma119Image*)bs->data;
@ -927,7 +923,7 @@ int iso_image_create(IsoImage *image, Ecma119WriteOpts *opts,
{
int ret;
struct burn_source *source;
Ecma119Image *target = NULL;
Ecma119Image *target= NULL;
if (image == NULL || opts == NULL || burn_src == NULL) {
return ISO_NULL_POINTER;

View File

@ -23,36 +23,39 @@ typedef struct ecma119_node Ecma119Node;
typedef struct Iso_File_Src IsoFileSrc;
typedef struct Iso_Image_Writer IsoImageWriter;
struct ecma119_image {
struct ecma119_image
{
IsoImage *image;
Ecma119Node *root;
unsigned int iso_level:2;
unsigned int iso_level :2;
/* extensions */
unsigned int rockridge:1;
unsigned int rockridge :1;
/* relaxed constraints */
unsigned int omit_version_numbers:1;
unsigned int allow_deep_paths:1;
// int relaxed_constraints; /**< see ecma119_relaxed_constraints_flag */
unsigned int omit_version_numbers :1;
unsigned int allow_deep_paths :1;
// int relaxed_constraints; /**< see ecma119_relaxed_constraints_flag */
/*
* Mode replace. If one of these flags is set, the correspodent values are
* replaced with values below.
*/
unsigned int replace_uid:1;
unsigned int replace_gid:1;
unsigned int replace_file_mode:1;
unsigned int replace_dir_mode:1;
unsigned int replace_uid :1;
unsigned int replace_gid :1;
unsigned int replace_file_mode :1;
unsigned int replace_dir_mode :1;
uid_t uid;
gid_t gid;
mode_t file_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
@ -64,9 +67,10 @@ struct ecma119_image {
char *output_charset;
uint32_t ms_block; /**< start block for a ms image */
time_t now; /**< Time at which writing began. */
off_t total_size; /**< Total size of the output. This only
* includes the current volume. */
time_t now; /**< Time at which writing began. */
/** Total size of the output. This only includes the current volume. */
off_t total_size;
uint32_t vol_space_size;
/*

View File

@ -25,7 +25,7 @@ int get_iso_name(Ecma119Image *img, IsoNode *iso, char **name)
{
int ret;
char *ascii_name;
char *isoname = NULL;
char *isoname= NULL;
if (iso->name == NULL) {
/* 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) {
iso_msg_note(img->image, LIBISO_FILE_IGNORED,
"File \"%s\" can't be added to image because is "
"greater than 4GB", iso->node.name);
"greater than 4GB", iso->node.name);
return 0;
}
@ -214,7 +214,7 @@ int create_tree(Ecma119Image *image, IsoNode *iso, Ecma119Node **tree,
int ret;
Ecma119Node *node;
int max_path;
char *iso_name = NULL;
char *iso_name= NULL;
if (image == NULL || iso == NULL || tree == NULL) {
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) {
iso_msg_note(image->image, LIBISO_FILE_IGNORED,
"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);
return 0;
}
}
switch(iso->type) {
switch (iso->type) {
case LIBISO_FILE:
ret = create_file(image, (IsoFile*)iso, &node);
break;
@ -249,8 +249,7 @@ int create_tree(Ecma119Image *image, IsoNode *iso, Ecma119Node **tree,
} else {
/* symlinks are only supported when RR is enabled */
iso_msg_note(image->image, LIBISO_FILE_IGNORED, "File \"%s\" "
"ignored. Symlinks need RockRidge extensions.",
iso->name);
"ignored. Symlinks need RockRidge extensions.", iso->name);
ret = 0;
}
break;
@ -260,8 +259,7 @@ int create_tree(Ecma119Image *image, IsoNode *iso, Ecma119Node **tree,
} else {
/* symlinks are only supported when RR is enabled */
iso_msg_note(image->image, LIBISO_FILE_IGNORED, "File \"%s\" "
"ignored. Special files need RockRidge extensions.",
iso->name);
"ignored. Special files need RockRidge extensions.", iso->name);
ret = 0;
}
break;
@ -331,8 +329,8 @@ void sort_tree(Ecma119Node *root)
{
size_t i;
qsort(root->info.dir.children, root->info.dir.nchildren,
sizeof(void*), cmp_node_name);
qsort(root->info.dir.children, root->info.dir.nchildren, sizeof(void*),
cmp_node_name);
for (i = 0; i < root->info.dir.nchildren; i++) {
if (root->info.dir.children[i]->type == ECMA119_DIR)
sort_tree(root->info.dir.children[i]);
@ -361,7 +359,7 @@ int contains_name(Ecma119Node *dir, const char *name)
*/
static
int mangle_single_dir(Ecma119Image *img, Ecma119Node *dir, int max_file_len,
int max_dir_len)
int max_dir_len)
{
int i, nchildren;
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 */
/* first, find all child with same name */
while (j + 1 < nchildren &&
!cmp_node_name(children + i, children + j + 1)) {
while (j + 1 < nchildren && !cmp_node_name(children + i, children + j
+ 1)) {
++j;
}
if (j == i) {
@ -538,8 +536,8 @@ int mangle_dir(Ecma119Image *img, Ecma119Node *dir, int max_file_len,
/* recurse */
for (i = 0; i < dir->info.dir.nchildren; ++i) {
if (dir->info.dir.children[i]->type == ECMA119_DIR) {
ret = mangle_dir(img, dir->info.dir.children[i],
max_file_len, max_dir_len);
ret = mangle_dir(img, dir->info.dir.children[i], max_file_len,
max_dir_len);
if (ret < 0) {
/* error */
return ret;
@ -575,8 +573,8 @@ int mangle_tree(Ecma119Image *img, int recurse)
* See IEEE P1282, section 4.1.5 for details
*/
static
int create_placeholder(Ecma119Node *parent,
Ecma119Node *real, Ecma119Node **node)
int create_placeholder(Ecma119Node *parent, Ecma119Node *real,
Ecma119Node **node)
{
Ecma119Node *ret;
@ -634,7 +632,7 @@ int reparent(Ecma119Node *child, Ecma119Node *parent)
Ecma119Node *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) {
ret = create_placeholder(child->parent, child, &placeholder);
if (ret < 0) {
@ -656,8 +654,8 @@ int reparent(Ecma119Node *child, Ecma119Node *parent)
/* add the child to its new parent */
child->parent = parent;
parent->info.dir.nchildren++;
parent->info.dir.children = realloc( parent->info.dir.children,
sizeof(void*) * parent->info.dir.nchildren );
parent->info.dir.children = realloc(parent->info.dir.children,
sizeof(void*) * parent->info.dir.nchildren);
parent->info.dir.children[parent->info.dir.nchildren - 1] = child;
return ISO_SUCCESS;
}

View File

@ -23,7 +23,8 @@ enum ecma119_node_type {
/**
* 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 */
size_t block;
@ -67,7 +68,8 @@ struct ecma119_node
/**< file, symlink, special, directory or placeholder */
enum ecma119_node_type type;
union {
union
{
IsoFileSrc *file;
// TODO this wastes too much memory, as dirs have much more
// atts than other kind of files. Replace with a pointer.

View File

@ -44,8 +44,7 @@ int iso_file_src_cmp(const void *n1, const void *n2)
return 1;
} else {
/* files belong to same device in same fs */
return (ino_id1 < ino_id2) ? -1 :
(ino_id1 > ino_id2) ? 1 : 0;
return (ino_id1 < ino_id2) ? -1 : (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);
}
static int
cmp_by_weight(const void *f1, const void *f2)
static int cmp_by_weight(const void *f1, const void *f2)
{
IsoFileSrc *f = *((IsoFileSrc**)f1);
IsoFileSrc *g = *((IsoFileSrc**)f2);
@ -137,7 +135,7 @@ int filesrc_writer_compute_data_blocks(IsoImageWriter *writer)
/* sort files by weight, if needed */
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 */
@ -239,18 +237,18 @@ int filesrc_writer_write_data(IsoImageWriter *writer)
* UPS, very ugly error, the best we can do is just to write
* 0's to image
*/
// TODO Stream needs a get_path function
iso_msg_sorry(t->image, LIBISO_FILE_CANT_WRITE,
"File XXX can't be openned. Filling with 0s.");
memset(buffer, 0, BLOCK_SIZE);
for (b = 0; b < nblocks; ++b) {
// TODO Stream needs a get_path function
iso_msg_sorry(t->image, LIBISO_FILE_CANT_WRITE,
"File XXX can't be openned. Filling with 0s.");
memset(buffer, 0, BLOCK_SIZE);
for (b = 0; b < nblocks; ++b) {
res = iso_write(t, buffer, BLOCK_SIZE);
if (res < 0) {
/* ko, writer error, we need to go out! */
return res;
}
}
continue;
}
continue;
}
/* write file contents to image */

View File

@ -14,8 +14,9 @@
#include <stdint.h>
struct Iso_File_Src {
unsigned int prev_img:1; /**< if the file comes from a previous image */
struct Iso_File_Src
{
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 */
int sort_weight;
IsoStream *stream;

View File

@ -6,7 +6,6 @@
* published by the Free Software Foundation. See COPYING file for details.
*/
/*
* 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.
*/
IsoFilesystem *lfs = NULL;
IsoFilesystem *lfs= NULL;
typedef struct
{
/* IsoFilesystem *fs; It seems not needed */
char *path;
unsigned int openned:2; /* 0: not openned, 1: file, 2:dir */
union {
unsigned int openned :2; /* 0: not openned, 1: file, 2:dir */
union
{
int fd;
DIR *dir;
} info;
@ -77,7 +77,7 @@ int lfs_lstat(IsoFileSource *src, struct stat *info)
int err;
/* error, choose an appropriate return code */
switch(errno) {
switch (errno) {
case EACCES:
err = ISO_FILE_ACCESS_DENIED;
break;
@ -116,7 +116,7 @@ int lfs_stat(IsoFileSource *src, struct stat *info)
int err;
/* error, choose an appropriate return code */
switch(errno) {
switch (errno) {
case EACCES:
err = ISO_FILE_ACCESS_DENIED;
break;
@ -176,7 +176,7 @@ int lfs_open(IsoFileSource *src)
* parsed in the lstat call above
*/
if (data->openned == 0) {
switch(errno) {
switch (errno) {
case EACCES:
err = ISO_FILE_ACCESS_DENIED;
break;
@ -205,7 +205,7 @@ int lfs_close(IsoFileSource *src)
}
data = src->data;
switch(data->openned) {
switch (data->openned) {
case 1: /* not dir */
ret = close(data->info.fd) == 0 ? ISO_SUCCESS : ISO_FILE_ERROR;
break;
@ -232,14 +232,14 @@ int lfs_read(IsoFileSource *src, void *buf, size_t count)
}
data = src->data;
switch(data->openned) {
switch (data->openned) {
case 1: /* not dir */
{
int ret;
ret = read(data->info.fd, buf, count);
if (ret < 0) {
/* error on read */
switch(errno) {
switch (errno) {
case EINTR:
ret = ISO_INTERRUPTED;
break;
@ -273,7 +273,7 @@ int lfs_readdir(IsoFileSource *src, IsoFileSource **child)
}
data = src->data;
switch(data->openned) {
switch (data->openned) {
case 1: /* not dir */
return ISO_FILE_IS_NOT_DIR;
case 2: /* directory */
@ -292,7 +292,7 @@ int lfs_readdir(IsoFileSource *src, IsoFileSource **child)
else
return 0; /* EOF */
}
if (strcmp(entry->d_name,".") && strcmp(entry->d_name,"..")) {
if (strcmp(entry->d_name, ".") && strcmp(entry->d_name, "..")) {
break;
}
}
@ -342,7 +342,7 @@ int lfs_readlink(IsoFileSource *src, char *buf, size_t bufsiz)
size = readlink(data->path, buf, bufsiz - 1);
if (size < 0) {
/* error */
switch(errno) {
switch (errno) {
case EACCES:
return ISO_FILE_ACCESS_DENIED;
case ENOTDIR:
@ -462,19 +462,19 @@ int iso_file_source_new_lfs(const char *path, IsoFileSource **src)
static
int lfs_get_root(IsoFilesystem *fs, IsoFileSource **root)
{
if (fs == NULL || root == NULL) {
if (fs == NULL || root == NULL) {
return ISO_NULL_POINTER;
}
return iso_file_source_new_lfs("/", root);
return iso_file_source_new_lfs("/", root);
}
static
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_file_source_new_lfs(path, file);
return iso_file_source_new_lfs(path, file);
}
static
@ -486,12 +486,12 @@ unsigned int lfs_get_id(IsoFilesystem *fs)
static
void lfs_fs_free(IsoFilesystem *fs)
{
lfs = NULL;
lfs = NULL;
}
int iso_local_filesystem_new(IsoFilesystem **fs)
{
if (fs == NULL) {
if (fs == NULL) {
return ISO_NULL_POINTER;
}
@ -500,7 +500,7 @@ int iso_local_filesystem_new(IsoFilesystem **fs)
iso_filesystem_ref(lfs);
} else {
lfs = malloc(sizeof(IsoFilesystem));
lfs = malloc(sizeof(IsoFilesystem));
if (lfs == NULL) {
return ISO_OUT_OF_MEM;
}
@ -513,6 +513,6 @@ int iso_local_filesystem_new(IsoFilesystem **fs)
lfs->get_id = lfs_get_id;
lfs->free = lfs_fs_free;
}
*fs = lfs;
return ISO_SUCCESS;
*fs = lfs;
return ISO_SUCCESS;
}

View File

@ -16,26 +16,26 @@ unsigned int iso_fs_global_id = 100;
void iso_file_source_ref(IsoFileSource *src)
{
++src->refcount;
++src->refcount;
}
void iso_file_source_unref(IsoFileSource *src)
{
if (--src->refcount == 0) {
src->class->free(src);
free(src);
}
if (--src->refcount == 0) {
src->class->free(src);
free(src);
}
}
void iso_filesystem_ref(IsoFilesystem *fs)
{
++fs->refcount;
++fs->refcount;
}
void iso_filesystem_unref(IsoFilesystem *fs)
{
if (--fs->refcount == 0) {
fs->free(fs);
free(fs);
}
if (--fs->refcount == 0) {
fs->free(fs);
free(fs);
}
}

View File

@ -14,8 +14,7 @@
*/
/*
* Some functions here will be moved to libisofs.h when we expose
* Sources.
* Some functions here will be moved to libisofs.h when we expose Sources.
*/
#include <sys/stat.h>
@ -233,7 +232,8 @@ typedef struct IsoFileSource_Iface
*/
} IsoFileSourceIface;
struct Iso_File_Source {
struct Iso_File_Source
{
const IsoFileSourceIface *class;
int refcount;
void *data;
@ -246,37 +246,44 @@ void iso_file_source_unref(IsoFileSource *src);
* this are just helpers to invoque methods in class
*/
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);
}
extern inline
char* iso_file_source_get_name(IsoFileSource *src) {
char* iso_file_source_get_name(IsoFileSource *src)
{
return src->class->get_name(src);
}
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);
}
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);
}
extern inline
int iso_file_source_open(IsoFileSource *src) {
int iso_file_source_open(IsoFileSource *src)
{
return src->class->open(src);
}
extern inline
int iso_file_source_close(IsoFileSource *src) {
int iso_file_source_close(IsoFileSource *src)
{
return src->class->close(src);
}
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);
}
@ -287,12 +294,14 @@ int iso_file_source_readdir(IsoFileSource *src, IsoFileSource **child)
}
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);
}
extern inline
IsoFilesystem* iso_file_source_get_filesystem(IsoFileSource *src) {
IsoFilesystem* iso_file_source_get_filesystem(IsoFileSource *src)
{
return src->class->get_filesystem(src);
}

View File

@ -77,7 +77,7 @@ int iso_image_new(const char *name, IsoImage **image)
return res;
}
img->refcount = 1;
img->recOpts = calloc(1,sizeof(IsoImageRecOpts));
img->recOpts = calloc(1, sizeof(IsoImageRecOpts));
if (img->recOpts == NULL) {
libiso_msgs_destroy(&img->messenger, 0);
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,
const char *data_preparer_id)
const char *data_preparer_id)
{
free(image->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,
const char *copyright_file_id)
const char *copyright_file_id)
{
free(image->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,
const char *abstract_file_id)
const char *abstract_file_id)
{
free(image->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;
}
void iso_image_set_biblio_file_id(IsoImage *image,
const char *biblio_file_id)
void iso_image_set_biblio_file_id(IsoImage *image, const char *biblio_file_id)
{
free(image->biblio_file_id);
image->biblio_file_id = strdup(biblio_file_id);

View File

@ -24,7 +24,8 @@
typedef struct Iso_Image_Rec_Opts IsoImageRecOpts;
struct Iso_Image {
struct Iso_Image
{
int refcount;
@ -32,11 +33,11 @@ struct Iso_Image {
char *volset_id;
char *volume_id; /**< Volume identifier. */
char *publisher_id; /**< Volume publisher. */
char *volume_id; /**< Volume identifier. */
char *publisher_id; /**< Volume publisher. */
char *data_preparer_id; /**< Volume data preparer. */
char *system_id; /**< Volume system identifier. */
char *application_id; /**< Volume application id */
char *system_id; /**< Volume system identifier. */
char *application_id; /**< Volume application id */
char *copyright_file_id;
char *abstract_file_id;
char *biblio_file_id;
@ -63,7 +64,8 @@ struct Iso_Image {
/**
* 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

View File

@ -58,28 +58,29 @@ enum IsoHideNodeFlag {
/**
* Holds the options for the image generation.
*/
typedef struct {
int level; /**< ISO level to write at. */
typedef struct
{
int level; /**< ISO level to write at. */
/** Which extensions to support. */
unsigned int rockridge:1;
unsigned int rockridge :1;
/* relaxed constraints */
unsigned int omit_version_numbers:1;
unsigned int allow_deep_paths:1;
unsigned int omit_version_numbers :1;
unsigned int allow_deep_paths :1;
//int relaxed_constraints; /**< see ecma119_relaxed_constraints_flag */
//unsigned int copy_eltorito:1;
/**<
* In multisession discs, select whether to copy el-torito catalog
* and boot image. Copy is needed for isolinux images, that need to
* be patched. However, it can lead to problems when the image is
* not present in the iso filesystem, because we can't figure out
* its size. In those cases, we only copy 1 block of data.
*/
/**<
* In multisession discs, select whether to copy el-torito catalog
* and boot image. Copy is needed for isolinux images, that need to
* be patched. However, it can lead to problems when the image is
* not present in the iso filesystem, because we can't figure out
* its size. In those cases, we only copy 1 block of data.
*/
/**< 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
@ -92,10 +93,10 @@ typedef struct {
* below. Note that for mode attributes, only the permissions are set, the
* file type remains unchanged.
*/
unsigned int replace_dir_mode:2;
unsigned int replace_file_mode:2;
unsigned int replace_uid:2;
unsigned int replace_gid:2;
unsigned int replace_dir_mode :2;
unsigned int replace_file_mode :2;
unsigned int replace_uid :2;
unsigned int replace_gid :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. */
@ -103,35 +104,35 @@ typedef struct {
gid_t gid; /** gid to use when replace_gid == 2. */
char *output_charset; /**< NULL to use default charset */
// uint32_t ms_block;
/**<
* Start block for multisession. When this is greater than 0,
* it's suppossed to be the lba of the next writable address
* on disc; all block lba on image will take this into account,
* and files from a previous session will not be written on
* image. This behavior is only suitable for images to be
* appended to a multisession disc.
* When this is 0, no multisession image will be created. If
* some files are taken from a previous image, its contents
* will be written again to the new image. Use this with new
* images or if you plan to modify an existin image.
*/
// struct data_source* src;
// /**<
// * When modifying a image, this is the source of the original
// * image, used to read file contents.
// * Otherwise it can be NULL.
// */
// uint8_t *overwrite;
// /**<
// * When not NULL, it should point to a buffer of at least
// * 64KiB, where libisofs will write the contents that should
// * be written at the beginning of a overwriteable media, to
// * grow the image.
// * You shoudl initialize the buffer either with 0s, or with
// * the contents of the first blocks of the image you're
// * growing. In most cases, 0 is good enought.
// */
// uint32_t ms_block;
/**<
* Start block for multisession. When this is greater than 0,
* it's suppossed to be the lba of the next writable address
* on disc; all block lba on image will take this into account,
* and files from a previous session will not be written on
* image. This behavior is only suitable for images to be
* appended to a multisession disc.
* When this is 0, no multisession image will be created. If
* some files are taken from a previous image, its contents
* will be written again to the new image. Use this with new
* images or if you plan to modify an existin image.
*/
// struct data_source* src;
// /**<
// * When modifying a image, this is the source of the original
// * image, used to read file contents.
// * Otherwise it can be NULL.
// */
// uint8_t *overwrite;
// /**<
// * When not NULL, it should point to a buffer of at least
// * 64KiB, where libisofs will write the contents that should
// * be written at the beginning of a overwriteable media, to
// * grow the image.
// * You shoudl initialize the buffer either with 0s, or with
// * the contents of the first blocks of the image you're
// * growing. In most cases, 0 is good enought.
// */
} Ecma119WriteOpts;
/**
@ -210,7 +211,7 @@ const char *iso_image_get_publisher_id(const IsoImage *image);
* Fill in the data preparer for a 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.
@ -248,7 +249,7 @@ const char *iso_image_get_application_id(const IsoImage *image);
* to a file on disc. Up to 37 characters.
*/
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.
@ -262,7 +263,7 @@ const char *iso_image_get_copyright_file_id(const IsoImage *image);
* to a file on disc. Up to 37 characters.
*/
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.
@ -275,8 +276,7 @@ const char *iso_image_get_abstract_file_id(const IsoImage *image);
* Fill biblio information for the image. Usually this refers
* to a file on disc. Up to 37 characters.
*/
void iso_image_set_biblio_file_id(IsoImage *image,
const char *biblio_file_id);
void iso_image_set_biblio_file_id(IsoImage *image, const char *biblio_file_id);
/**
* 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);
/*
TODO #00007 expose Strem and thi function:
int iso_tree_add_new_file(IsoDir *parent, const char *name, stream, file)
*/
TODO #00007 expose Strem and thi function:
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,
@ -808,7 +808,7 @@ int iso_tree_path_to_node(IsoImage *image, const char *path, IsoNode **node);
* @return >0 for success, <=0 for error
*/
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
* least the given minimum_severity. This message and any older message of

View File

@ -25,13 +25,13 @@ void iso_msg_debug(IsoImage *img, const char *fmt, ...)
vsnprintf(msg, MAX_MSG_LEN, fmt, 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);
}
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_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, ...)
{
char msg[MAX_MSG_LEN];
char msg[MAX_MSG_LEN];
va_list ap;
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, ...)
{
char msg[MAX_MSG_LEN];
char msg[MAX_MSG_LEN];
va_list ap;
va_start(ap, fmt);
vsnprintf(msg, MAX_MSG_LEN, fmt, ap);
va_end(ap);
libiso_msgs_submit(img->messenger, -1, error_code,
LIBISO_MSGS_SEV_WARNING, LIBISO_MSGS_PRIO_MEDIUM,
msg, 0, 0);
libiso_msgs_submit(img->messenger, -1, error_code, LIBISO_MSGS_SEV_WARNING,
LIBISO_MSGS_PRIO_MEDIUM, msg, 0, 0);
}
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_start(ap, fmt);
vsnprintf(msg, MAX_MSG_LEN, fmt, ap);
va_end(ap);
libiso_msgs_submit(img->messenger, -1, error_code,
LIBISO_MSGS_SEV_SORRY, LIBISO_MSGS_PRIO_HIGH,
msg, 0, 0);
libiso_msgs_submit(img->messenger, -1, error_code, LIBISO_MSGS_SEV_SORRY,
LIBISO_MSGS_PRIO_HIGH, msg, 0, 0);
}
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_start(ap, fmt);
vsnprintf(msg, MAX_MSG_LEN, fmt, ap);
va_end(ap);
libiso_msgs_submit(img->messenger, -1, error_code,
LIBISO_MSGS_SEV_FATAL, LIBISO_MSGS_PRIO_HIGH,
msg, 0, 0);
libiso_msgs_submit(img->messenger, -1, error_code, LIBISO_MSGS_SEV_FATAL,
LIBISO_MSGS_PRIO_HIGH, 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,
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);
if (ret <= 0)
return 0;
ret = libiso_msgs__text_to_sev(print_severity, &print_sevno, 0);
if (ret <= 0)
return 0;
ret = libiso_msgs_set_severities(img->messenger, queue_sevno,
print_sevno, print_id, 0);
if (ret <= 0)
return 0;
return 1;
ret = libiso_msgs__text_to_sev(queue_severity, &queue_sevno, 0);
if (ret <= 0)
return 0;
ret = libiso_msgs__text_to_sev(print_severity, &print_sevno, 0);
if (ret <= 0)
return 0;
ret = libiso_msgs_set_severities(img->messenger, queue_sevno, print_sevno,
print_id, 0);
if (ret <= 0)
return 0;
return 1;
}
#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
*/
int iso_image_obtain_msgs(IsoImage *img, char *minimum_severity,
int *error_code, char msg_text[], int *os_errno,
char severity[])
int *error_code, char msg_text[], int *os_errno,
char severity[])
{
int ret, minimum_sevno, sevno, priority;
char *textpt, *sev_name;
struct libiso_msgs_item *item = NULL;
int ret, minimum_sevno, sevno, priority;
char *textpt, *sev_name;
struct libiso_msgs_item *item= NULL;
if (img == NULL)
return 0;
if (img == NULL)
return 0;
ret = libiso_msgs__text_to_sev(minimum_severity, &minimum_sevno, 0);
if (ret <= 0)
return 0;
ret = libiso_msgs_obtain(img->messenger, &item, minimum_sevno,
LIBISO_MSGS_PRIO_ZERO, 0);
if (ret <= 0)
goto ex;
ret = libiso_msgs_item_get_msg(item, error_code, &textpt, os_errno, 0);
if (ret <= 0)
goto ex;
strncpy(msg_text, textpt, ISO_MSGS_MESSAGE_LEN-1);
if(strlen(textpt) >= ISO_MSGS_MESSAGE_LEN)
msg_text[ISO_MSGS_MESSAGE_LEN-1] = 0;
ret = libiso_msgs__text_to_sev(minimum_severity, &minimum_sevno, 0);
if (ret <= 0)
return 0;
ret = libiso_msgs_obtain(img->messenger, &item, minimum_sevno,
LIBISO_MSGS_PRIO_ZERO, 0);
if (ret <= 0)
goto ex;
ret = libiso_msgs_item_get_msg(item, error_code, &textpt, os_errno, 0);
if (ret <= 0)
goto ex;
strncpy(msg_text, textpt, ISO_MSGS_MESSAGE_LEN-1);
if (strlen(textpt) >= ISO_MSGS_MESSAGE_LEN)
msg_text[ISO_MSGS_MESSAGE_LEN-1] = 0;
severity[0]= 0;
ret = libiso_msgs_item_get_rank(item, &sevno, &priority, 0);
if(ret <= 0)
goto ex;
ret = libiso_msgs__sev_to_text(sevno, &sev_name, 0);
if(ret <= 0)
goto ex;
strcpy(severity,sev_name);
severity[0]= 0;
ret = libiso_msgs_item_get_rank(item, &sevno, &priority, 0);
if (ret <= 0)
goto ex;
ret = libiso_msgs__sev_to_text(sevno, &sev_name, 0);
if (ret <= 0)
goto ex;
strcpy(severity, sev_name);
ret = 1;
ex:
libiso_msgs_destroy_item(img->messenger, &item, 0);
return ret;
ret = 1;
ex: ;
libiso_msgs_destroy_item(img->messenger, &item, 0);
return ret;
}
void *iso_image_get_messenger(IsoImage *img)
{
return img->messenger;
return img->messenger;
}

View File

@ -31,7 +31,7 @@ void iso_node_ref(IsoNode *node)
void iso_node_unref(IsoNode *node)
{
if (--node->refcount == 0) {
switch(node->type) {
switch (node->type) {
case LIBISO_DIR:
{
IsoNode *child = ((IsoDir*)node)->children;
@ -168,7 +168,6 @@ mode_t iso_node_get_mode(const IsoNode *node)
return node->mode;
}
/**
* Set the user id for the node. This attribute is only useful when
* Rock Ridge extensions are enabled.
@ -437,8 +436,7 @@ void iso_dir_iter_free(IsoDirIter *iter)
free(iter);
}
static IsoNode**
iso_dir_find_node(IsoDir *dir, IsoNode *node)
static IsoNode** iso_dir_find_node(IsoDir *dir, IsoNode *node)
{
IsoNode **pos;
pos = &(dir->children);

View File

@ -34,14 +34,14 @@ struct Iso_Node
*/
int refcount;
/**< Type of the IsoNode, do not confuse with mode */
/** Type of the IsoNode, do not confuse with mode */
enum IsoNodeType type;
char *name; /**< Real name, in default charset */
mode_t mode; /**< protection */
uid_t uid; /**< user ID of owner */
gid_t gid; /**< group ID of owner */
uid_t uid; /**< user ID of owner */
gid_t gid; /**< group ID of owner */
/* TODO #00001 : consider adding new timestamps */
time_t atime; /**< time of last access */
@ -75,10 +75,10 @@ struct Iso_File
*/
uint32_t msblock;
/**
* 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
*/
/**
* 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
*/
int sort_weight;
IsoStream *stream;
};

View File

@ -20,8 +20,8 @@ static
int susp_append(Ecma119Image *t, struct susp_info *susp, uint8_t *data)
{
susp->n_susp_fields++;
susp->susp_fields = realloc(susp->susp_fields,
sizeof(void*) * susp->n_susp_fields);
susp->susp_fields = realloc(susp->susp_fields, sizeof(void*)
* susp->n_susp_fields);
if (susp->susp_fields == NULL) {
return ISO_MEM_ERROR;
}
@ -34,8 +34,8 @@ static
int susp_append_ce(Ecma119Image *t, struct susp_info *susp, uint8_t *data)
{
susp->n_ce_susp_fields++;
susp->ce_susp_fields = realloc(susp->ce_susp_fields,
sizeof(void*) * susp->n_ce_susp_fields);
susp->ce_susp_fields = realloc(susp->ce_susp_fields, sizeof(void*)
* susp->n_ce_susp_fields);
if (susp->ce_susp_fields == NULL) {
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);
if (ret < 0) {
iso_msg_sorry(t->image, LIBISO_CHARSET_ERROR,
"Charset conversion error. Can't convert %s from %s to %s",
n->node->name, t->input_charset, t->output_charset);
"Charset conversion error. Can't convert %s from %s to %s",
n->node->name, t->input_charset, t->output_charset);
/* use the original name, it's the best we can do */
name = strdup(n->node->name);
@ -285,8 +285,8 @@ char *get_rr_name(Ecma119Image *t, Ecma119Node *n)
* Whether to add or not to CE
*/
static
int rrip_add_NM(Ecma119Image *t, struct susp_info *susp,
char *name, int size, int flags, int ce)
int rrip_add_NM(Ecma119Image *t, struct susp_info *susp, char *name, int size,
int flags, int ce)
{
uint8_t *NM = malloc(size + 5);
if (NM == NULL) {
@ -325,8 +325,7 @@ int rrip_add_NM(Ecma119Image *t, struct susp_info *susp,
* 1 on success, < 0 on error
*/
static
int rrip_SL_append_comp(size_t *n, uint8_t ***comps,
char *s, int size, char fl)
int rrip_SL_append_comp(size_t *n, uint8_t ***comps, char *s, int size, char fl)
{
uint8_t *comp = malloc(size + 2);
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.
*/
static
int rrip_add_SL(Ecma119Image *t, struct susp_info *susp,
uint8_t **comp, size_t n, int ce)
int rrip_add_SL(Ecma119Image *t, struct susp_info *susp, uint8_t **comp,
size_t n, int ce)
{
int ret, i, j;
@ -388,7 +387,7 @@ int rrip_add_SL(Ecma119Image *t, struct susp_info *susp,
SL[1] = 'L';
SL[2] = total_comp_len + 5;
SL[3] = 1;
SL[4] = 1; /* CONTINUE */
SL[4] = 1; /* CONTINUE */
pos = 5;
for (j = written; j < i; j++) {
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;
memcpy(&ER[8], "IEEE_1282", 9);
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, "
"PISCATAWAY, NJ, USA FOR THE 1282 SPECIFICATION.", 93);
"PISCATAWAY, NJ, USA FOR THE 1282 SPECIFICATION.", 93);
/** This always goes to continuation area */
return susp_append_ce(t, susp, ER);
@ -531,8 +530,8 @@ int susp_add_SP(Ecma119Image *t, struct susp_info *susp)
* @return
* 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 space, size_t *ce)
size_t rrip_calc_len(Ecma119Image *t, Ecma119Node *n, int type, size_t space,
size_t *ce)
{
size_t su_size;
@ -754,7 +753,7 @@ int rrip_get_susp_fields(Ecma119Image *t, Ecma119Node *n, int type,
int ret;
size_t i;
Ecma119Node *node;
char *name = NULL;
char *name= NULL;
if (t == NULL || n == NULL || info == NULL) {
return ISO_NULL_POINTER;
@ -841,7 +840,7 @@ int rrip_get_susp_fields(Ecma119Image *t, Ecma119Node *n, int type,
size_t namelen;
/* 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 */
name = get_rr_name(t, n);
@ -884,7 +883,8 @@ int rrip_get_susp_fields(Ecma119Image *t, Ecma119Node *n, int type,
if (clen == 0) {
/* this refers to the roor directory, '/' */
cflag = 1 << 3;
} if (clen == 1 && prev[0] == '.') {
}
if (clen == 1 && prev[0] == '.') {
clen = 0;
cflag = 1 << 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
* other SL entry
*/
ret = rrip_SL_append_comp(&n_comp, &comps,
prev + fit,
clen - fit - 2,
0);
ret = rrip_SL_append_comp(&n_comp, &comps, prev
+ fit, clen - fit - 2, 0);
if (ret < 0) {
goto add_susp_cleanup;
}
@ -972,10 +970,8 @@ int rrip_get_susp_fields(Ecma119Image *t, Ecma119Node *n, int type,
if (ret < 0) {
goto add_susp_cleanup;
}
ret = rrip_SL_append_comp(&n_comp, &comps,
prev + 248,
strlen(prev + 248),
0x00);
ret = rrip_SL_append_comp(&n_comp, &comps, prev
+ 248, strlen(prev + 248), 0x00);
if (ret < 0) {
goto add_susp_cleanup;
}
@ -1076,7 +1072,6 @@ int rrip_get_susp_fields(Ecma119Image *t, Ecma119Node *n, int type,
}
}
} else {
/* "." or ".." entry */
@ -1113,7 +1108,7 @@ int rrip_get_susp_fields(Ecma119Image *t, Ecma119Node *n, int type,
free(name);
return ISO_SUCCESS;
add_susp_cleanup:;
add_susp_cleanup: ;
free(name);
susp_info_free(info);
return ret;
@ -1160,7 +1155,7 @@ int rrip_write_ce_fields(Ecma119Image *t, struct susp_info *info)
{
size_t i;
uint8_t padding[BLOCK_SIZE];
int ret = ISO_SUCCESS;
int ret= ISO_SUCCESS;
if (info->n_ce_susp_fields == 0) {
return ret;
@ -1181,7 +1176,7 @@ int rrip_write_ce_fields(Ecma119Image *t, struct susp_info *info)
ret = iso_write(t, padding, i);
}
write_ce_field_cleanup:;
write_ce_field_cleanup: ;
/* free ce_susp_fields */
for (i = 0; i < info->n_ce_susp_fields; ++i) {
free(info->ce_susp_fields[i]);

View File

@ -28,7 +28,6 @@
#include "ecma119.h"
/**
* 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
@ -66,8 +65,8 @@ struct susp_info
* @return
* 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 space, size_t *ce);
size_t rrip_calc_len(Ecma119Image *t, Ecma119Node *n, int type, size_t space,
size_t *ce);
/**
* Fill a struct susp_info with the RR/SUSP entries needed for a given

View File

@ -98,33 +98,39 @@ void iso_stream_ref(IsoStream *stream);
void iso_stream_unref(IsoStream *stream);
extern inline
int iso_stream_open(IsoStream *stream) {
int iso_stream_open(IsoStream *stream)
{
return stream->class->open(stream);
}
extern inline
int iso_stream_close(IsoStream *stream) {
int iso_stream_close(IsoStream *stream)
{
return stream->class->close(stream);
}
extern inline
off_t iso_stream_get_size(IsoStream *stream) {
off_t iso_stream_get_size(IsoStream *stream)
{
return stream->class->get_size(stream);
}
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);
}
extern inline
int iso_stream_is_repeatable(IsoStream *stream) {
int iso_stream_is_repeatable(IsoStream *stream)
{
return stream->class->is_repeatable(stream);
}
extern inline
int iso_stream_get_id(IsoStream *stream, unsigned int *fs_id,
dev_t *dev_id, ino_t *ino_id) {
int iso_stream_get_id(IsoStream *stream, unsigned int *fs_id, dev_t *dev_id,
ino_t *ino_id)
{
return stream->class->get_id(stream, fs_id, dev_id, ino_id);
}

View File

@ -458,8 +458,8 @@ int iso_add_dir_aux(IsoImage *image, IsoDir *parent, IsoFileSource *dir)
result = builder->create_node(builder, image, file, &new);
if (result < 0) {
iso_msg_debug(image, "Error %d when adding file %s",
result, iso_file_source_get_path(file));
iso_msg_debug(image, "Error %d when adding file %s", result,
iso_file_source_get_path(file));
if (image->recOpts->report) {
action = image->recOpts->report(file, result, flag);

View File

@ -28,7 +28,6 @@ int int_pow(int base, int power)
return result;
}
int strconv(const char *str, const char *icharset, const char *ocharset,
char **output)
{
@ -190,7 +189,7 @@ int str2ascii(const char *icharset, const char *input, char **output)
}
n = iconv(conv, &src, &inbytes, &ret, &outbytes);
while(n == -1) {
while (n == -1) {
/* The destination buffer is too small. Stops here. */
if (errno == E2BIG)
break;
@ -238,8 +237,8 @@ static int valid_d_char(char c)
static int valid_a_char(char c)
{
return (c >= ' ' && c <= '"') || (c >= '%' && c <= '?')
|| (c >= 'A' && c <= 'Z') || (c == '_');
return (c >= ' ' && c <= '"') || (c >= '%' && c <= '?') ||
(c >= 'A' && c <= 'Z') || (c == '_');
}
static
@ -253,7 +252,7 @@ char *iso_dirid(const char *src, int size)
len = size;
}
for (i = 0; i < len; i++) {
char c = toupper(src[i]);
char c= toupper(src[i]);
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 *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;
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. */
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 : '_';
}
@ -305,7 +304,7 @@ char *iso_1_fileid(const char *src)
/* 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]);
char c= toupper(src[lname + 1 + i]);
dest[pos++] = valid_d_char(c) ? c : '_';
}
@ -339,8 +338,8 @@ char *iso_2_fileid(const char *src)
} else {
lext = strlen(dot + 1);
lname = strlen(src) - lext - 1;
lnext = (strlen(src) > 31 && lext > 3)
? (lname < 27 ? 30 - lname : 3) : lext;
lnext = (strlen(src) > 31 && lext > 3) ? (lname < 27 ? 30 - lname : 3)
: lext;
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. */
for (i = 0; i < lnname; i++) {
char c = toupper(src[i]);
char c= toupper(src[i]);
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. */
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 : '_';
}
@ -368,102 +367,6 @@ char *iso_2_fileid(const char *src)
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 ret;
@ -490,7 +393,7 @@ int str2d_char(const char *icharset, const char *input, char **output)
len = strlen(ascii);
for (i = 0; i < len; ++i) {
char c = toupper(ascii[i]);
char c= toupper(ascii[i]);
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);
for (i = 0; i < len; ++i) {
char c = toupper(ascii[i]);
char c= toupper(ascii[i]);
ascii[i] = valid_a_char(c) ? c : '_';
}

View File

@ -16,13 +16,15 @@
* implementation of Julienne Walker.
*/
struct iso_rbnode {
struct iso_rbnode
{
void *data;
struct iso_rbnode *ch[2];
unsigned int red:1;
unsigned int red :1;
};
struct iso_rbtree {
struct iso_rbtree
{
struct iso_rbnode *root;
size_t size;
int (*compare)(const void *a, const void *b);
@ -40,8 +42,7 @@ struct iso_rbtree {
* @param tree
* Location where the tree structure will be stored.
*/
int
iso_rbtree_new(int (*compare)(const void*, const void*), IsoRBTree **tree)
int iso_rbtree_new(int (*compare)(const void*, const void*), IsoRBTree **tree)
{
if (compare == NULL || tree == NULL) {
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
* element of the tree, so you can use it to free any related data.
*/
void
iso_rbtree_destroy(IsoRBTree *tree, void (*free_data)(void *))
void iso_rbtree_destroy(IsoRBTree *tree, void (*free_data)(void *))
{
if (tree == NULL) {
return;
@ -116,7 +116,7 @@ struct iso_rbnode *iso_rbnode_new(void *data)
{
struct iso_rbnode *rn = malloc(sizeof(struct iso_rbnode));
if ( rn != NULL ) {
if (rn != NULL) {
rn->data = data;
rn->red = 1;
rn->ch[0] = NULL;
@ -154,15 +154,15 @@ int iso_rbtree_insert(IsoRBTree *tree, void *data, void **item)
/* Empty tree case */
tree->root = iso_rbnode_new(data);
if (tree->root == NULL) {
return ISO_MEM_ERROR;
return ISO_MEM_ERROR;
}
new = data;
added = 1;
} 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 *p, *q; /* Iterator & parent */
struct iso_rbnode *g, *t; /* Grandparent & parent */
struct iso_rbnode *p, *q; /* Iterator & parent */
int dir = 0, last = 0;
int comp;
@ -243,7 +243,6 @@ size_t iso_rbtree_get_size(IsoRBTree *tree)
return tree->size;
}
static
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
* has size + 1 length.
*/
void **
iso_rbtree_to_array(IsoRBTree *tree)
void ** iso_rbtree_to_array(IsoRBTree *tree)
{
void **array;

View File

@ -28,8 +28,7 @@ struct Iso_Image_Writer
};
/**
* This is the function all Writers shoudl call to write data to
* image.
* This is the function all Writers shoudl call to write data to image.
* Currently, it is just a wrapper for write(2) Unix system call.
*
* It is implemented in ecma119.c