From e2711613a26a931180264c077339acc1c8887918 Mon Sep 17 00:00:00 2001 From: Christophe Grenier Date: Wed, 15 May 2013 13:53:12 +0200 Subject: [PATCH] New functions log_all_partitions() and init_list_part() --- src/log_part.c | 11 +++++++++-- src/log_part.h | 3 ++- src/photorec.c | 15 ++++++++++++++- src/photorec.h | 1 + src/ppartsel.c | 20 ++------------------ 5 files changed, 28 insertions(+), 22 deletions(-) diff --git a/src/log_part.c b/src/log_part.c index 5efd7de3..dd60a682 100644 --- a/src/log_part.c +++ b/src/log_part.c @@ -31,14 +31,21 @@ #include "log_part.h" #include "intrf.h" /* aff_part_aux */ -void log_partition(const disk_t *disk_car, const partition_t *partition) +void log_partition(const disk_t *disk, const partition_t *partition) { const char *msg; char buffer_part_size[100]; - msg=aff_part_aux(AFF_PART_ORDER|AFF_PART_STATUS, disk_car, partition); + msg=aff_part_aux(AFF_PART_ORDER|AFF_PART_STATUS, disk, partition); log_info("%s",msg); size_to_unit(partition->part_size, buffer_part_size); if(partition->info[0]!='\0') log_info("\n %s, %s", partition->info, buffer_part_size); log_info("\n"); } + +void log_all_partitions(const disk_t *disk, const list_part_t *list_part) +{ + list_part_t *element; + for(element=list_part; element!=NULL; element=element->next) + log_partition(disk, element->part); +} diff --git a/src/log_part.h b/src/log_part.h index 52ea10af..0ceadfd1 100644 --- a/src/log_part.h +++ b/src/log_part.h @@ -25,7 +25,8 @@ extern "C" { #endif -void log_partition(const disk_t *disk_car,const partition_t *partition); +void log_partition(const disk_t *disk, const partition_t *partition); +void log_all_partitions(const disk_t *disk, const list_part_t *list_part); #ifdef __cplusplus } /* closing brace for extern "C" */ diff --git a/src/photorec.c b/src/photorec.c index 0896e3ac..ef1fb57a 100644 --- a/src/photorec.c +++ b/src/photorec.c @@ -1070,4 +1070,17 @@ void status_inc(struct ph_param *params, const struct ph_options *options) } } - +list_part_t *init_list_part(disk_t *disk, const struct ph_options *options) +{ + int insert_error=0; + list_part_t *list_part; + partition_t *partition_wd; + list_part=disk->arch->read_part(disk, (options!=NULL?options->verbose:0), 0); + partition_wd=new_whole_disk(disk); + list_part=insert_new_partition(list_part, partition_wd, 0, &insert_error); + if(insert_error>0) + { + free(partition_wd); + } + return list_part; +} diff --git a/src/photorec.h b/src/photorec.h index eade7362..c5599620 100644 --- a/src/photorec.h +++ b/src/photorec.h @@ -83,6 +83,7 @@ uint64_t set_search_start(struct ph_param *params, alloc_data_t **new_current_se void params_reset(struct ph_param *params, const struct ph_options *options); const char *status_to_name(const photorec_status_t status); void status_inc(struct ph_param *params, const struct ph_options *options); +list_part_t *init_list_part(disk_t *disk, const struct ph_options *options); #ifdef __cplusplus } /* closing brace for extern "C" */ #endif diff --git a/src/ppartsel.c b/src/ppartsel.c index 7a6a1c7a..caa34058 100644 --- a/src/ppartsel.c +++ b/src/ppartsel.c @@ -99,26 +99,10 @@ void menu_photorec(struct ph_param *params, struct ph_options *options, alloc_da }; #endif params->blocksize=0; - list_part=params->disk->arch->read_part(params->disk,options->verbose,0); - { - int insert_error=0; - partition_t *partition_wd; - partition_wd=new_whole_disk(params->disk); - list_part=insert_new_partition(list_part, partition_wd, 0, &insert_error); - if(insert_error>0) - { - free(partition_wd); - } - } + list_part=init_list_part(params->disk, options); if(list_part==NULL) return; - { - list_part_t *element; - for(element=list_part;element!=NULL;element=element->next) - { - log_partition(params->disk,element->part); - } - } + log_all_partitions(params->disk, list_part); if(list_part->next!=NULL) { current_element_num=1;