summaryrefslogtreecommitdiffstats
path: root/src/partmac.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2018-03-17 17:29:28 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2018-03-17 17:29:28 +0100
commit09ecae700f224a23cfd8f63f98cebeccbe768cc0 (patch)
tree83fbfb551cc9330a02dfb6762e2c4b8e6015eecb /src/partmac.c
parent331f0ef77e62140d0ee9252c33b23b383aa73084 (diff)
Use new functions check_command(), skip_comma_in_command() and get_int_from_command() to parse command line arguments
Diffstat (limited to 'src/partmac.c')
-rw-r--r--src/partmac.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/partmac.c b/src/partmac.c
index f3f86e7..36e5e19 100644
--- a/src/partmac.c
+++ b/src/partmac.c
@@ -216,14 +216,12 @@ list_part_t *add_partition_mac_cli(disk_t *disk_car,list_part_t *list_part, char
assert(current_cmd!=NULL);
new_partition->part_offset=disk_car->sector_size;
new_partition->part_size=disk_car->disk_size-disk_car->sector_size;
- while(*current_cmd[0]==',')
- (*current_cmd)++;
while(1)
{
- if(strncmp(*current_cmd,"s,",2)==0)
+ skip_comma_in_command(current_cmd);
+ if(check_command(current_cmd,"s,",2)==0)
{
uint64_t part_offset;
- (*current_cmd)+=2;
part_offset=new_partition->part_offset;
new_partition->part_offset=(uint64_t)ask_number_cli(
current_cmd,
@@ -234,9 +232,8 @@ list_part_t *add_partition_mac_cli(disk_t *disk_car,list_part_t *list_part, char
(uint64_t)disk_car->sector_size;
new_partition->part_size=new_partition->part_size + part_offset - new_partition->part_offset;
}
- else if(strncmp(*current_cmd,"S,",2)==0)
+ else if(check_command(current_cmd,"S,",2)==0)
{
- (*current_cmd)+=2;
new_partition->part_size=(uint64_t)ask_number_cli(
current_cmd,
(new_partition->part_offset+new_partition->part_size-1)/disk_car->sector_size,
@@ -246,9 +243,8 @@ list_part_t *add_partition_mac_cli(disk_t *disk_car,list_part_t *list_part, char
(uint64_t)disk_car->sector_size +
disk_car->sector_size - new_partition->part_offset;
}
- else if(strncmp(*current_cmd,"T,",2)==0)
+ else if(check_command(current_cmd,"T,",2)==0)
{
- (*current_cmd)+=2;
change_part_type_cli(disk_car,new_partition,current_cmd);
}
else if(new_partition->part_size>0 && new_partition->part_type_mac>0)