summaryrefslogtreecommitdiffstats
path: root/src/intrf.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2013-05-14 09:07:36 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2013-05-14 09:07:36 +0200
commit3c70faa00155a6a6d2ecb404a7f558a3ee638e86 (patch)
treeb7b74912c00ceb4bedc2573541213aa367c16746 /src/intrf.c
parentc7373142a8955fbfe9eacb204c95da1a96e72b21 (diff)
Move some code to new function get_partition_status()
Diffstat (limited to 'src/intrf.c')
-rw-r--r--src/intrf.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/src/intrf.c b/src/intrf.c
index cd5d6c7..f2aed67 100644
--- a/src/intrf.c
+++ b/src/intrf.c
@@ -130,6 +130,23 @@ void screen_buffer_to_log(void)
log_info("%s\n",intr_buffer_screen[i]);
}
+int get_partition_status(const partition_t *partition)
+{
+ /* Don't marked as D(eleted) an entry that is not a partition */
+ if(partition->order==NO_ORDER && partition->status==STATUS_DELETED)
+ return ' ';
+ switch(partition->status)
+ {
+ case STATUS_PRIM: return 'P';
+ case STATUS_PRIM_BOOT: return '*';
+ case STATUS_EXT: return 'E';
+ case STATUS_EXT_IN_EXT: return 'X';
+ case STATUS_LOG: return 'L';
+ case STATUS_DELETED: return 'D';
+ default: return ' ';
+ }
+}
+
const char *aff_part_aux(const unsigned int newline, const disk_t *disk_car, const partition_t *partition)
{
char status=' ';
@@ -145,28 +162,14 @@ const char *aff_part_aux(const unsigned int newline, const disk_t *disk_car, con
msg[sizeof(msg)-1]=0;
if((newline&AFF_PART_ORDER)==AFF_PART_ORDER)
{
- if((partition->status!=STATUS_EXT_IN_EXT) && (partition->order!=NO_ORDER))
+ if(partition->status!=STATUS_EXT_IN_EXT && partition->order!=NO_ORDER)
pos+=snprintf(&msg[pos],sizeof(msg)-pos-1,"%2u ", partition->order);
else
pos+=snprintf(&msg[pos],sizeof(msg)-pos-1," ");
}
if((newline&AFF_PART_STATUS)==AFF_PART_STATUS)
{
- switch(partition->status)
- {
- case STATUS_PRIM: status='P'; break;
- case STATUS_PRIM_BOOT: status='*'; break;
- case STATUS_EXT: status='E'; break;
- case STATUS_EXT_IN_EXT: status='X'; break;
- case STATUS_LOG: status='L'; break;
- case STATUS_DELETED: status='D'; break;
- default: status=' '; break;
- }
- /* Don't marked as D(eleted) an entry that is not a partition */
- if((newline&AFF_PART_ORDER)==AFF_PART_ORDER &&
- partition->order==NO_ORDER &&
- partition->status==STATUS_DELETED)
- status=' ';
+ status=get_partition_status(partition);
}
pos+=snprintf(&msg[pos],sizeof(msg)-pos-1,"%c", status);
if(arch->get_partition_typename(partition)!=NULL)