From fe6613d7b9a2d73882be9b9f752a75fb603af245 Mon Sep 17 00:00:00 2001 From: Jaime Thomas Date: Mon, 19 May 2008 05:00:55 +0000 Subject: [PATCH] Clean up headers a bit, and begin to add the improved image creation --- experimental/ecdb/trunk/src/ecdb.c | 4 +- experimental/ecdb/trunk/src/ecdb_burn.c | 2 +- experimental/ecdb/trunk/src/ecdb_burn.h | 9 +-- experimental/ecdb/trunk/src/ecdb_common.h | 13 ++++ experimental/ecdb/trunk/src/ecdb_drives.c | 3 + experimental/ecdb/trunk/src/ecdb_drives.h | 6 +- experimental/ecdb/trunk/src/ecdb_image.c | 91 +++++++++++++++++++++++ experimental/ecdb/trunk/src/ecdb_image.h | 6 +- experimental/ecdb/trunk/src/ecdb_misc.h | 10 +-- 9 files changed, 127 insertions(+), 17 deletions(-) diff --git a/experimental/ecdb/trunk/src/ecdb.c b/experimental/ecdb/trunk/src/ecdb.c index 4993a25a..4794b4b2 100644 --- a/experimental/ecdb/trunk/src/ecdb.c +++ b/experimental/ecdb/trunk/src/ecdb.c @@ -97,9 +97,9 @@ ecdb_setup(void) if (!ecdb_aquire_drive_info()) { printf("Aquiring drives failed!\n"); - return 0; + return FALSE; } - return 1; + return TRUE; } diff --git a/experimental/ecdb/trunk/src/ecdb_burn.c b/experimental/ecdb/trunk/src/ecdb_burn.c index 1d679299..845e1b90 100644 --- a/experimental/ecdb/trunk/src/ecdb_burn.c +++ b/experimental/ecdb/trunk/src/ecdb_burn.c @@ -315,5 +315,5 @@ ecdb_burn_finished(void *data, int type, void *event) FREE(t); FREE(proj); ecore_event_add(ECORE_EVENT_SIGNAL_EXIT, NULL, NULL, NULL); - return 0; + return FALSE; } diff --git a/experimental/ecdb/trunk/src/ecdb_burn.h b/experimental/ecdb/trunk/src/ecdb_burn.h index dc734d92..bb1c59f0 100644 --- a/experimental/ecdb/trunk/src/ecdb_burn.h +++ b/experimental/ecdb/trunk/src/ecdb_burn.h @@ -1,10 +1,9 @@ #ifndef ECDB_BURN_H #define ECDB_BURN_H -int ecdb_burn_project(Ecdb_Burn_Project *proj); -int ecdb_erase_disc(Ecdb_Erase_Project *proj); - -Ecdb_Burn_Project *ecdb_burn_project_new(void); -Ecdb_Erase_Project *ecdb_erase_project_new(void); +int ecdb_burn_project(Ecdb_Burn_Project *proj); +int ecdb_erase_disc(Ecdb_Erase_Project *proj); +Ecdb_Burn_Project *ecdb_burn_project_new(void); +Ecdb_Erase_Project *ecdb_erase_project_new(void); #endif diff --git a/experimental/ecdb/trunk/src/ecdb_common.h b/experimental/ecdb/trunk/src/ecdb_common.h index 0c1b31b4..ad94eb62 100644 --- a/experimental/ecdb/trunk/src/ecdb_common.h +++ b/experimental/ecdb/trunk/src/ecdb_common.h @@ -111,4 +111,17 @@ struct _Ecdb_Erase_Project /* Typecast a pointer to an Ecdb_Erase_Project */ #define ECDB_ERASE(proj) ((Ecdb_Erase_Project *) proj) +/* Typecast a pointer to an Ecdb_Source */ +#define ECDB_SOURCE(src) ((Ecdb_Source *) src) + +typedef struct _Ecdb_Source Ecdb_Source; +struct _Ecdb_Source +{ + const char *dst; + unsigned char rec:1; + unsigned char num_children; + Ecdb_Source **children; + IsoNode *node; +}; + #endif diff --git a/experimental/ecdb/trunk/src/ecdb_drives.c b/experimental/ecdb/trunk/src/ecdb_drives.c index 66428fe4..e394d206 100644 --- a/experimental/ecdb/trunk/src/ecdb_drives.c +++ b/experimental/ecdb/trunk/src/ecdb_drives.c @@ -28,6 +28,9 @@ ecdb_aquire_drive_info(void) drive = calloc(1, sizeof(Ecdb_Drive_Info)); + if (!drive) + return FALSE; + /* It would be nice if there was an easier way to do this */ drive->product = strdup(drives_current[i].product); drive->vendor = strdup(drives_current[i].vendor); diff --git a/experimental/ecdb/trunk/src/ecdb_drives.h b/experimental/ecdb/trunk/src/ecdb_drives.h index e51e5a2c..95003a5b 100644 --- a/experimental/ecdb/trunk/src/ecdb_drives.h +++ b/experimental/ecdb/trunk/src/ecdb_drives.h @@ -1,8 +1,8 @@ #ifndef ECDB_DRIVES_H #define ECDB_DRIVES_H -int ecdb_aquire_drive_info(void); -void ecdb_print_drive_info(void); -int ecdb_aquire_drive(Ecdb_Project *proj, unsigned int idx); +int ecdb_aquire_drive_info(void); +void ecdb_print_drive_info(void); +int ecdb_aquire_drive(Ecdb_Project *proj, unsigned int idx); #endif diff --git a/experimental/ecdb/trunk/src/ecdb_image.c b/experimental/ecdb/trunk/src/ecdb_image.c index 6b6f1415..afdab278 100644 --- a/experimental/ecdb/trunk/src/ecdb_image.c +++ b/experimental/ecdb/trunk/src/ecdb_image.c @@ -1,5 +1,96 @@ #include "ecdb.h" +int ecdb_source_init(Ecdb_Source *src); + +Ecdb_Source * +ecdb_source_new(void) +{ + Ecdb_Source *src; + + src = calloc(1, sizeof(Ecdb_Source)); + if (!src) + return NULL; + if (!ecdb_source_init(src)) + { + FREE(src); + return NULL; + } + + return src; +} + +int +ecdb_source_init(Ecdb_Source *src) +{ + src->rec = FALSE; + src->num_children = 0; + src->children = calloc(1, sizeof(Ecdb_Source)); + if (!src->children) + return FALSE; + src->children[src->num_children] = NULL; + return TRUE; +} + +void +ecdb_source_data_set(Ecdb_Source *src, const char *dst, unsigned char rec) +{ + if (!src) + return; + + src->dst = dst; + src->rec = rec; +} + +void +ecdb_source_child_append(Ecdb_Source *src, Ecdb_Source *child) +{ + src->num_children++; + src->children = realloc(src->children, sizeof(Ecdb_Source) * + (src->num_children + 1)); + src->children[src->num_children] = child; + src->children[src->num_children + 1] = NULL; +} + +void +ecdb_source_add_children_rec(Ecdb_Source *parent, IsoImage *image) +{ + IsoDir *cd; + IsoNode *cn; + Ecdb_Source *cs; + int i; + + if ((!parent) || (!image)) + return; + + i = 0; + while ((cs = parent->children[i])) + { + if (cs->rec) + iso_tree_add_dir_rec(image, ISO_DIR(parent->node), + cs->dst); + if (cs->num_children) + { + /* If not created above, make one here */ + if (!iso_tree_path_to_node(image, cs->dst, &cn)) + { + iso_tree_add_new_dir(ISO_DIR(parent->node), + cs->dst, &cd); + cs->node = ISO_NODE(cd); + } + else + cs->node = cn; + ecdb_source_add_children_rec(cs, image); + } + + /* file */ + if ((!cs->rec) && (!cs->num_children)) + iso_tree_add_node(image, ISO_DIR(parent->node), + cs->dst, NULL); + i++; + } +} +/* Deprecated code */ + /* Some limitations here need to be worked out * Handle: audio, etc */ BurnSource * diff --git a/experimental/ecdb/trunk/src/ecdb_image.h b/experimental/ecdb/trunk/src/ecdb_image.h index 7849994c..394a74ef 100644 --- a/experimental/ecdb/trunk/src/ecdb_image.h +++ b/experimental/ecdb/trunk/src/ecdb_image.h @@ -1,7 +1,11 @@ #ifndef ECDB_IMAGE_H #define ECDB_IMAGE_H -BurnSource *ecdb_image_project(Ecdb_Burn_Project *proj); +Ecdb_Source *ecdb_source_new(void); +void ecdb_source_data_set(Ecdb_Source *src, const char *dst, + unsigned char rec); +void ecdb_source_child_append(Ecdb_Source *src, Ecdb_Source *child); +BurnSource *ecdb_image_project(Ecdb_Burn_Project *proj); #endif diff --git a/experimental/ecdb/trunk/src/ecdb_misc.h b/experimental/ecdb/trunk/src/ecdb_misc.h index 509defc4..6c0849b2 100644 --- a/experimental/ecdb/trunk/src/ecdb_misc.h +++ b/experimental/ecdb/trunk/src/ecdb_misc.h @@ -1,10 +1,10 @@ #ifndef ECDB_MISC_H #define ECDB_MISC_H -Ecdb_Project *ecdb_project_new(void); -int ecdb_project_init(Ecdb_Project *proj); -int ecdb_shutdown(void *data, int type, void *event); -void ecdb_burn_init(void); -void ecdb_image_init(void); +Ecdb_Project *ecdb_project_new(void); +int ecdb_project_init(Ecdb_Project *proj); +int ecdb_shutdown(void *data, int type, void *event); +void ecdb_burn_init(void); +void ecdb_image_init(void); #endif