summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2013-05-15 17:53:26 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2013-05-15 17:53:26 +0200
commit816032140813972e230863a002b4acd1b15d2bcf (patch)
tree9c2b26ea8c5680b6127217c7c3933fb8f5c30252
parent2dd9cec608a056ded9df373610854918f492a339 (diff)
split add_partition() into add_partition_cli() and add_partition_ncurses()
-rw-r--r--src/Makefile.am12
-rw-r--r--src/addpart.c46
-rw-r--r--src/addpart.h2
-rw-r--r--src/addpartn.c61
-rw-r--r--src/addpartn.h23
-rw-r--r--src/adv.c6
-rw-r--r--src/intrface.c9
-rw-r--r--src/partgptn.c2
-rw-r--r--src/partgptn.h2
-rw-r--r--src/parti386n.c2
-rw-r--r--src/parti386n.h2
-rw-r--r--src/partmacn.c2
-rw-r--r--src/partmacn.h2
-rw-r--r--src/partsunn.c2
-rw-r--r--src/partsunn.h2
-rw-r--r--src/partxboxn.c2
-rw-r--r--src/partxboxn.h2
-rw-r--r--src/ppartsel.c4
18 files changed, 125 insertions, 58 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 182bd02..d673ef2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -19,8 +19,8 @@ base_H = alignio.h autoset.h common.h crc.h ewf.h fnctdsk.h hdaccess.h hdwin32
fs_C = analyse.c bfs.c bsd.c btrfs.c cramfs.c exfat.c fat.c fatx.c ext2.c jfs.c gfs2.c hfs.c hfsp.c hpfs.c luks.c lvm.c md.c netware.c ntfs.c rfs.c savehdr.c sun.c swap.c sysv.c ufs.c vmfs.c wbfs.c xfs.c zfs.c
fs_H = analyse.h bfs.h bsd.h btrfs.h cramfs.h exfat.h fat.h fatx.h ext2.h jfs_superblock.h jfs.h gfs2.h hfs.h hfsp.h hpfs.h luks.h lvm.h md.h netware.h ntfs.h rfs.h savehdr.h sun.h swap.h sysv.h ufs.h vmfs.h wbfs.h xfs.h zfs.h
-testdisk_ncurses_C = addpart.c adv.c askloc.c chgarch.c chgarchn.c chgtype.c chgtypen.c dimage.c dirn.c dirpart.c diskacc.c diskcapa.c edit.c ext2_sb.c ext2_sbn.c fat1x.c fat32.c fat_adv.c fat_cluster.c fatn.c geometry.c geometryn.c godmode.c hiddenn.c intrface.c intrfn.c nodisk.c ntfs_adv.c ntfs_fix.c ntfs_udl.c parti386n.c partgptn.c partmacn.c partsunn.c partxboxn.c tanalyse.c tbanner.c tdelete.c tdiskop.c tdisksel.c testdisk.c texfat.c thfs.c tload.c tlog.c tmbrcode.c tntfs.c toptions.c tpartwr.c
-testdisk_ncurses_H = addpart.h adv.h askloc.h chgarch.h chgarchn.h chgtype.h chgtypen.h dimage.h dirn.h dirpart.h diskacc.h diskcapa.h edit.h ext2_sb.h ext2_sbn.h fat1x.h fat32.h fat_adv.h fat_cluster.h fatn.h geometry.h geometryn.h godmode.h hiddenn.h intrface.h intrfn.h nodisk.h ntfs_fix.h ntfs_udl.h partgptn.h parti386n.h partmacn.h partsunn.h partxboxn.h tanalyse.h tdelete.h tdiskop.h tdisksel.h texfat.h thfs.h tload.h tlog.h tmbrcode.h tntfs.h toptions.h tpartwr.h
+testdisk_ncurses_C = addpart.c addpartn.c adv.c askloc.c chgarch.c chgarchn.c chgtype.c chgtypen.c dimage.c dirn.c dirpart.c diskacc.c diskcapa.c edit.c ext2_sb.c ext2_sbn.c fat1x.c fat32.c fat_adv.c fat_cluster.c fatn.c geometry.c geometryn.c godmode.c hiddenn.c intrface.c intrfn.c nodisk.c ntfs_adv.c ntfs_fix.c ntfs_udl.c parti386n.c partgptn.c partmacn.c partsunn.c partxboxn.c tanalyse.c tbanner.c tdelete.c tdiskop.c tdisksel.c testdisk.c texfat.c thfs.c tload.c tlog.c tmbrcode.c tntfs.c toptions.c tpartwr.c
+testdisk_ncurses_H = addpart.h addpartn.h adv.h askloc.h chgarch.h chgarchn.h chgtype.h chgtypen.h dimage.h dirn.h dirpart.h diskacc.h diskcapa.h edit.h ext2_sb.h ext2_sbn.h fat1x.h fat32.h fat_adv.h fat_cluster.h fatn.h geometry.h geometryn.h godmode.h hiddenn.h intrface.h intrfn.h nodisk.h ntfs_fix.h ntfs_udl.h partgptn.h parti386n.h partmacn.h partsunn.h partxboxn.h tanalyse.h tdelete.h tdiskop.h tdisksel.h texfat.h thfs.h tload.h tlog.h tmbrcode.h tntfs.h toptions.h tpartwr.h
testdisk_SOURCES = $(base_C) $(base_H) $(fs_C) $(fs_H) $(testdisk_ncurses_C) $(testdisk_ncurses_H) dir.c dir.h exfat_dir.c exfat_dir.h ext2_dir.c ext2_dir.h ext2_inc.h fat_dir.c fat_dir.h ntfs_dir.c ntfs_dir.h ntfs_inc.h partgptw.c rfs_dir.c rfs_dir.h setdate.c setdate.h $(ICON_TESTDISK) next.c next.h
@@ -290,12 +290,12 @@ file_C = filegen.c \
file_H = ext2.h filegen.h file_jpg.h file_sp3.h file_tar.h file_tiff.h file_txt.h ole.h pe.h suspend.h
-photorec_C = photorec.c phcfg.c dir.c exfatp.c ext2grp.c ext2_dir.c ext2p.c fat_dir.c fatp.c file_found.c geometry.c ntfs_dir.c ntfsp.c poptions.c sessionp.c setdate.c dfxml.c list.c
+photorec_C = photorec.c phcfg.c addpart.c dir.c exfatp.c ext2grp.c ext2_dir.c ext2p.c fat_dir.c fatp.c file_found.c geometry.c ntfs_dir.c ntfsp.c poptions.c sessionp.c setdate.c dfxml.c list.c
-photorec_H = photorec.h phcfg.h dir.h exfatp.h ext2grp.h ext2p.h ext2_dir.h ext2_inc.h fat_dir.h fatp.h file_found.h geometry.h memmem.h ntfs_dir.h ntfsp.h ntfs_inc.h poptions.h sessionp.h setdate.h dfxml.h
+photorec_H = photorec.h phcfg.h addpart.h dir.h exfatp.h ext2grp.h ext2p.h ext2_dir.h ext2_inc.h fat_dir.h fatp.h file_found.h geometry.h memmem.h ntfs_dir.h ntfsp.h ntfs_inc.h poptions.h sessionp.h setdate.h dfxml.h
-photorec_ncurses_C = addpart.c askloc.c chgarch.c chgarchn.c chgtype.c chgtypen.c fat_cluster.c fat_unformat.c geometryn.c hiddenn.c intrfn.c nodisk.c parti386n.c partgptn.c partmacn.c partsunn.c partxboxn.c pbanner.c pblocksize.c pdisksel.c pfree_whole.c phbf.c phbs.c phnc.c phrecn.c ppartsel.c
-photorec_ncurses_H = addpart.h askloc.h chgarch.h chgarchn.h chgtype.h chgtypen.h fat_cluster.h fat_unformat.h geometryn.h hiddenn.h intrfn.h nodisk.h parti386n.h partgptn.h partmacn.h partsunn.h partxboxn.h pblocksize.h pdisksel.h pfree_whole.h pnext.h phbf.h phbs.h phnc.h phrecn.h ppartsel.h
+photorec_ncurses_C = addpartn.c askloc.c chgarch.c chgarchn.c chgtype.c chgtypen.c fat_cluster.c fat_unformat.c geometryn.c hiddenn.c intrfn.c nodisk.c parti386n.c partgptn.c partmacn.c partsunn.c partxboxn.c pbanner.c pblocksize.c pdisksel.c pfree_whole.c phbf.c phbs.c phnc.c phrecn.c ppartsel.c
+photorec_ncurses_H = addpartn.h askloc.h chgarch.h chgarchn.h chgtype.h chgtypen.h fat_cluster.h fat_unformat.h geometryn.h hiddenn.h intrfn.h nodisk.h parti386n.h partgptn.h partmacn.h partsunn.h partxboxn.h pblocksize.h pdisksel.h pfree_whole.h pnext.h phbf.h phbs.h phnc.h phrecn.h ppartsel.h
photorec_SOURCES = phmain.c $(photorec_C) $(photorec_H) $(photorec_ncurses_C) $(photorec_ncurses_H) $(file_C) $(file_H) $(base_C) $(base_H) partgptro.c $(fs_C) $(fs_H) $(ICON_PHOTOREC) suspend_no.c
diff --git a/src/addpart.c b/src/addpart.c
index a4b2ea3..a365413 100644
--- a/src/addpart.c
+++ b/src/addpart.c
@@ -32,13 +32,6 @@
#include "partmac.h"
#include "partsun.h"
#include "partxbox.h"
-#ifdef HAVE_NCURSES
-#include "parti386n.h"
-#include "partgptn.h"
-#include "partmacn.h"
-#include "partsunn.h"
-#include "partxboxn.h"
-#endif
#include "addpart.h"
extern const arch_fnct_t arch_gpt;
@@ -47,32 +40,19 @@ extern const arch_fnct_t arch_mac;
extern const arch_fnct_t arch_sun;
extern const arch_fnct_t arch_xbox;
-list_part_t *add_partition(disk_t *disk_car, list_part_t *list_part, char **current_cmd)
+list_part_t *add_partition_cli(disk_t *disk, list_part_t *list_part, char **current_cmd)
{
- if(*current_cmd!=NULL)
- {
- if(disk_car->arch==&arch_gpt)
- return add_partition_gpt_cli(disk_car, list_part, current_cmd);
- else if(disk_car->arch==&arch_i386)
- return add_partition_i386_cli(disk_car, list_part, current_cmd);
- else if(disk_car->arch==&arch_mac)
- return add_partition_mac_cli(disk_car, list_part, current_cmd);
- else if(disk_car->arch==&arch_sun)
- return add_partition_sun_cli(disk_car, list_part, current_cmd);
- else if(disk_car->arch==&arch_xbox)
- return add_partition_xbox_cli(disk_car, list_part, current_cmd);
- }
-#ifdef HAVE_NCURSES
- if(disk_car->arch==&arch_gpt)
- return add_partition_gpt_ncurses(disk_car, list_part, current_cmd);
- else if(disk_car->arch==&arch_i386)
- return add_partition_i386_ncurses(disk_car, list_part, current_cmd);
- else if(disk_car->arch==&arch_mac)
- return add_partition_mac_ncurses(disk_car, list_part, current_cmd);
- else if(disk_car->arch==&arch_sun)
- return add_partition_sun_ncurses(disk_car, list_part, current_cmd);
- else if(disk_car->arch==&arch_xbox)
- return add_partition_xbox_ncurses(disk_car, list_part, current_cmd);
-#endif
+ if(*current_cmd==NULL)
+ return list_part;
+ if(disk->arch==&arch_gpt)
+ return add_partition_gpt_cli(disk, list_part, current_cmd);
+ else if(disk->arch==&arch_i386)
+ return add_partition_i386_cli(disk, list_part, current_cmd);
+ else if(disk->arch==&arch_mac)
+ return add_partition_mac_cli(disk, list_part, current_cmd);
+ else if(disk->arch==&arch_sun)
+ return add_partition_sun_cli(disk, list_part, current_cmd);
+ else if(disk->arch==&arch_xbox)
+ return add_partition_xbox_cli(disk, list_part, current_cmd);
return list_part;
}
diff --git a/src/addpart.h b/src/addpart.h
index 26cc86b..ab66262 100644
--- a/src/addpart.h
+++ b/src/addpart.h
@@ -20,4 +20,4 @@
*/
-list_part_t *add_partition(disk_t *disk_car, list_part_t *list_part, char **current_cmd);
+list_part_t *add_partition_cli(disk_t *disk, list_part_t *list_part, char **current_cmd);
diff --git a/src/addpartn.c b/src/addpartn.c
new file mode 100644
index 0000000..948a361
--- /dev/null
+++ b/src/addpartn.c
@@ -0,0 +1,61 @@
+/*
+
+ File: addpartn.c
+
+ Copyright (C) 1998-2013 Christophe GRENIER <grenier@cgsecurity.org>
+
+ This software is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write the Free Software Foundation, Inc., 51
+ Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include "types.h"
+#include "common.h"
+#include "parti386.h"
+#include "partgpt.h"
+#include "partmac.h"
+#include "partsun.h"
+#include "partxbox.h"
+#include "parti386n.h"
+#include "partgptn.h"
+#include "partmacn.h"
+#include "partsunn.h"
+#include "partxboxn.h"
+#include "addpartn.h"
+
+extern const arch_fnct_t arch_gpt;
+extern const arch_fnct_t arch_i386;
+extern const arch_fnct_t arch_mac;
+extern const arch_fnct_t arch_sun;
+extern const arch_fnct_t arch_xbox;
+
+list_part_t *add_partition_ncurses(disk_t *disk, list_part_t *list_part)
+{
+ if(disk->arch==&arch_gpt)
+ return add_partition_gpt_ncurses(disk, list_part);
+ else if(disk->arch==&arch_i386)
+ return add_partition_i386_ncurses(disk, list_part);
+ else if(disk->arch==&arch_mac)
+ return add_partition_mac_ncurses(disk, list_part);
+ else if(disk->arch==&arch_sun)
+ return add_partition_sun_ncurses(disk, list_part);
+ else if(disk->arch==&arch_xbox)
+ return add_partition_xbox_ncurses(disk, list_part);
+ return list_part;
+}
diff --git a/src/addpartn.h b/src/addpartn.h
new file mode 100644
index 0000000..e0638c1
--- /dev/null
+++ b/src/addpartn.h
@@ -0,0 +1,23 @@
+/*
+
+ File: addpartn.h
+
+ Copyright (C) 2013 Christophe GRENIER <grenier@cgsecurity.org>
+
+ This software is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write the Free Software Foundation, Inc., 51
+ Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ */
+
+list_part_t *add_partition_ncurses(disk_t *disk, list_part_t *list_part);
diff --git a/src/adv.c b/src/adv.c
index 184a30f..2606afe 100644
--- a/src/adv.c
+++ b/src/adv.c
@@ -58,7 +58,7 @@
#include "tntfs.h"
#include "thfs.h"
#include "askloc.h"
-#include "addpart.h"
+#include "addpartn.h"
#include "io_redir.h"
extern const arch_fnct_t arch_gpt;
@@ -385,15 +385,17 @@ void interface_adv(disk_t *disk_car, const int verbose,const int dump_ind, const
case 'Q':
part_free_list(list_part);
return;
+#ifdef HAVE_NCURSES
case 'a':
case 'A':
if(disk_car->arch!=&arch_none)
{
- list_part=add_partition(disk_car, list_part, current_cmd);
+ list_part=add_partition_ncurses(disk_car, list_part);
current_element=list_part;
rewrite=1;
}
break;
+#endif
}
#ifdef HAVE_NCURSES
if(current_element!=NULL)
diff --git a/src/intrface.c b/src/intrface.c
index 38d22cf..48fd438 100644
--- a/src/intrface.c
+++ b/src/intrface.c
@@ -31,9 +31,6 @@
#include "common.h"
#include "lang.h"
#include "intrf.h"
-#ifdef HAVE_NCURSES
-#include "intrfn.h"
-#endif
#include "godmode.h"
#include "fnctdsk.h"
#include "chgtypen.h"
@@ -44,6 +41,10 @@
#include "tload.h"
#include "intrface.h"
#include "addpart.h"
+#ifdef HAVE_NCURSES
+#include "intrfn.h"
+#include "addpartn.h"
+#endif
#define INTER_DISK_X 0
#define INTER_DISK_Y 7
@@ -342,7 +343,7 @@ static list_part_t *ask_structure_ncurses(disk_t *disk_car,list_part_t *list_par
case 'A':
if(disk_car->arch != &arch_none)
{
- list_part=add_partition(disk_car,list_part, current_cmd);
+ list_part=add_partition_ncurses(disk_car, list_part);
rewrite=1;
offset=0;
pos_num=0;
diff --git a/src/partgptn.c b/src/partgptn.c
index c362adf..c0faf3a 100644
--- a/src/partgptn.c
+++ b/src/partgptn.c
@@ -52,7 +52,7 @@
extern const arch_fnct_t arch_gpt;
-list_part_t *add_partition_gpt_ncurses(disk_t *disk_car,list_part_t *list_part, char **current_cmd)
+list_part_t *add_partition_gpt_ncurses(disk_t *disk_car, list_part_t *list_part)
{
int position=0;
int done = FALSE;
diff --git a/src/partgptn.h b/src/partgptn.h
index 7e9db1e..626344e 100644
--- a/src/partgptn.h
+++ b/src/partgptn.h
@@ -23,7 +23,7 @@
extern "C" {
#endif
-list_part_t *add_partition_gpt_ncurses(disk_t *disk_car,list_part_t *list_part, char **current_cmd);
+list_part_t *add_partition_gpt_ncurses(disk_t *disk, list_part_t *list_part);
#ifdef __cplusplus
} /* closing brace for extern "C" */
diff --git a/src/parti386n.c b/src/parti386n.c
index 5fc87a6..342b473 100644
--- a/src/parti386n.c
+++ b/src/parti386n.c
@@ -41,7 +41,7 @@
extern const arch_fnct_t arch_i386;
-list_part_t *add_partition_i386_ncurses(disk_t *disk_car,list_part_t *list_part, char **current_cmd)
+list_part_t *add_partition_i386_ncurses(disk_t *disk_car, list_part_t *list_part)
{
CHS_t start,end;
partition_t *new_partition=partition_new(&arch_i386);
diff --git a/src/parti386n.h b/src/parti386n.h
index e07b50e..eb01fcb 100644
--- a/src/parti386n.h
+++ b/src/parti386n.h
@@ -23,7 +23,7 @@
extern "C" {
#endif
-list_part_t *add_partition_i386_ncurses(disk_t *disk_car,list_part_t *list_part, char **current_cmd);
+list_part_t *add_partition_i386_ncurses(disk_t *disk, list_part_t *list_part);
#ifdef __cplusplus
} /* closing brace for extern "C" */
diff --git a/src/partmacn.c b/src/partmacn.c
index 45b1ff8..8a7fa56 100644
--- a/src/partmacn.c
+++ b/src/partmacn.c
@@ -65,7 +65,7 @@ void write_part_mac_warning_ncurses(void)
#endif
}
-list_part_t *add_partition_mac_ncurses(disk_t *disk_car,list_part_t *list_part, char **current_cmd)
+list_part_t *add_partition_mac_ncurses(disk_t *disk_car, list_part_t *list_part)
{
int position=0;
int done = FALSE;
diff --git a/src/partmacn.h b/src/partmacn.h
index 30fe028..43eefec 100644
--- a/src/partmacn.h
+++ b/src/partmacn.h
@@ -25,7 +25,7 @@ extern "C" {
#endif
void write_part_mac_warning_ncurses(void);
-list_part_t *add_partition_mac_ncurses(disk_t *disk_car,list_part_t *list_part, char **current_cmd);
+list_part_t *add_partition_mac_ncurses(disk_t *disk, list_part_t *list_part);
#ifdef __cplusplus
} /* closing brace for extern "C" */
diff --git a/src/partsunn.c b/src/partsunn.c
index 4a78db1..e9db981 100644
--- a/src/partsunn.c
+++ b/src/partsunn.c
@@ -40,7 +40,7 @@
extern const arch_fnct_t arch_sun;
-list_part_t *add_partition_sun_ncurses(disk_t *disk_car,list_part_t *list_part, char **current_cmd)
+list_part_t *add_partition_sun_ncurses(disk_t *disk_car, list_part_t *list_part)
{
CHS_t start,end;
partition_t *new_partition=partition_new(&arch_sun);
diff --git a/src/partsunn.h b/src/partsunn.h
index a49ff2a..ecb4356 100644
--- a/src/partsunn.h
+++ b/src/partsunn.h
@@ -23,7 +23,7 @@
extern "C" {
#endif
-list_part_t *add_partition_sun_ncurses(disk_t *disk_car,list_part_t *list_part, char **current_cmd);
+list_part_t *add_partition_sun_ncurses(disk_t *disk, list_part_t *list_part);
#ifdef __cplusplus
} /* closing brace for extern "C" */
diff --git a/src/partxboxn.c b/src/partxboxn.c
index 7777f0b..5914391 100644
--- a/src/partxboxn.c
+++ b/src/partxboxn.c
@@ -40,7 +40,7 @@
extern const arch_fnct_t arch_xbox;
-list_part_t *add_partition_xbox_ncurses(disk_t *disk_car,list_part_t *list_part, char **current_cmd)
+list_part_t *add_partition_xbox_ncurses(disk_t *disk_car, list_part_t *list_part)
{
int position=0;
int done = FALSE;
diff --git a/src/partxboxn.h b/src/partxboxn.h
index 872eae7..84b29ac 100644
--- a/src/partxboxn.h
+++ b/src/partxboxn.h
@@ -23,7 +23,7 @@
extern "C" {
#endif
-list_part_t *add_partition_xbox_ncurses(disk_t *disk_car,list_part_t *list_part, char **current_cmd);
+list_part_t *add_partition_xbox_ncurses(disk_t *disk, list_part_t *list_part);
#ifdef __cplusplus
} /* closing brace for extern "C" */
diff --git a/src/ppartsel.c b/src/ppartsel.c
index caa3405..e8149b3 100644
--- a/src/ppartsel.c
+++ b/src/ppartsel.c
@@ -51,7 +51,7 @@
#include "askloc.h"
#include "geometry.h"
#include "geometryn.h"
-#include "addpart.h"
+#include "addpartn.h"
#include "intrfn.h"
#include "poptions.h"
@@ -432,7 +432,7 @@ void menu_photorec(struct ph_param *params, struct ph_options *options, alloc_da
case 'A':
if(params->disk->arch != &arch_none)
{
- list_part=add_partition(params->disk, list_part, &params->cmd_run);
+ list_part=add_partition_ncurses(params->disk, list_part);
current_element=list_part;
current_element_num=0;
}